You don't have to test everything, all the time

After we updated our unit tests to cover the missed catch block, our Statements coverage is now 100%. However, if we examine our code, we'll find two modules that still lack unit tests:

  • validate: User validation function at src/validators/users/create.js
  • injectHandlerDependencies: Utility function at src/utils/inject-handler-dependencies.js

They did not show up in the coverage report because the unit tests never imported those files. But do we need to write unit tests for every unit? To answer this question, you should ask yourself "Do I have confidence that this block of code works?" If the answer is "yes", then writing additional tests may be unnecessary.

Code coverage for a unit should ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.