GithubHelp home page GithubHelp logo

test-utils-docs's Introduction

test-utils-docs's People

Contributors

afontcu avatar akiomik avatar angelogulina avatar buffpojken avatar cexbrayat avatar dallasread avatar dependabot[bot] avatar dobromir-hristov avatar jessicasachs avatar lmiller1990 avatar mohit-vora avatar pearofducks avatar rafaelachermann avatar rak-phillip avatar rdarcy1 avatar vvanpo avatar yamacent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

test-utils-docs's Issues

feat: add HTTP requests section

This is one of the common pain points when someone starts testing their apps.

Thus, I would

  • showcase how to mock GET requests.
  • showcase how to mock POST requests.
  • showcase how to test failing HTTP requests.

I'd use jest.mock to perform the API mocking/stubbing

guide: Essentials

This comment by @bencodezen in discord regarding docs-next:

Our goal in "Essentials" is to get people up and running with just enough and nothing more

Made me think about something that has been on my mind for days. Right now, I see VTU as a toolset with 2 categories of stuff:

  • Set 1: basic, "essentials" tools such as find, trigger, setValue, emitted, and so on (I believe the list doesn't grow much larger, tbh).
  • Set 2: advanced stuff: stubbing, setProps, findComponent, and whatever flavour of shallow mounting we end up using.

I think docs should follow this structure. An Essentials category, with everything you need to get up and running if you're writing your first tests with Vue.

Then, and only then, we unveil advanced features which require deeper knowledge.

Does it make sense? Would we be able to "split" all VTU-next features in two sets, or at least "prioritize" them in a way that allow us to teach them sequentially?

Suggested way for docs to show mocking axios?

Hi! ๐Ÿ‘‹ I was writing docs for Making HTTP Requests, and I had this doubt.

There are several ways of mocking a module in Jest, and I'm not sure which one is the one we should showcase in docs:

jest.mock('axios')
axios.get = jest.fn().mockResolvedValue(posts)
jest.mock('axios', () => ({
  get: jest.fn(() => posts)
}))
jest.mock('axios')
axios.get.mockResolvedValue(fakePostList)

any preference? any downsides?

disclaimer: docs will mention alternatives such as axios-mock-adapter or msw, but I want to keep it simple for the example.

feat: add "How to test passing props" section

One of the common frictions in VTU is how to test that given a prop, something happens in the component under testing.

We should explain:

  • How to pass in props, and assert the expected behavior (a special case is a prop that triggers some sort of behaviour in created or mounted).
  • How to "update" that prop. This might change depending on the final VTU API (related), but we could "officialy" suggest using a Wrapper component for the time being.

feat: add Forms section

I believe handling forms is one of the main usages of Vue, and one of the common target of tests.

Thus, I would

  • showcase how to perform simple, basic assertions and interactions on a form.
  • showcase how to use VTU + vuelidate (once they update to Vue 3)
  • showcase how to use VTU + vee-validate (once they update to Vue 3)

feat: add Vuex section

  • showcase how to test a component that interacts with a store.
  • showcase how to mock/stub some potentially expensive Vuex actions (through jest.mock).
  • explain how, if needed, testing a Vuex store in isolation is no different from testing any other JS function/object.

I'm assuming Vuex 4, by the way.

docs: Continuous deployment

I tried to set a Github Action to automatically build and deploy docs, but I lack the ability to set up Secrets in this repo. I guess we should wait until both repos are merged and then work from there?

Also it would be cool to leverage Netlify, just as docs-next is doing.

I'll keep updating manually for now ๐Ÿ‘

feat: Add "Write Vue code that's easy to test" section

I was thinking of adding a section somewhere with several tips on writing testable code:

  • Extract requests into services to simplify mocking.
  • Extract complex methods and test them in isolation.
  • Do not test implementation details (with examples).
  • Build small things to have simpler test scenarios.
  • Write tests before writing production code (the ultimate technique to write testable code ๐Ÿ˜†).

Also, we could point to some smells:

  • Large "setup/arrange" blocks on each test.
  • Breaking tests on a refactor (from my POV this is critical but I'm not 100% sure it would fit in this section).

Sounds cool? More ideas?

disclaimer: There's a lot of content on the internet about these topics. I think this section should be focused on Vue stuff with Vue examples, and then maybe links to well-established content.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.