test-utils-docs icon indicating copy to clipboard operation
test-utils-docs copied to clipboard

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

Open afontcu opened this issue 5 years ago • 1 comments

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.

afontcu avatar Jun 07 '20 17:06 afontcu

These are definitely useful.

I think we should focus on the Vue specific things first, though - like you said, there is a lot of content out there for the other topics.

That said, I definitely like this idea.

lmiller1990 avatar Jun 12 '20 07:06 lmiller1990