Code coverage tools
There are many reasons to write tests and we went through some of them in the previous section. The main one is always to provide value to our codebase and make it more robust.
Because of that, I am always skeptical when it comes to counting the number of tests, the lines of code, and the test coverage. I suggest people don't focus on numbers but on the value that the tests can provide.
However, in some scenarios it is useful to get some measurement of the coverage and keep track of the numbers. In big projects with many different modules, doing so makes it easy to spot files that have not been adequately tested or that have not been tested at all.
Once again, Jest provides all the equipment you need to run your tests and of course it provides the functionalities to measure and store the code coverage information.
It uses Istanbul, one of the most popular code coverage libraries, which you will have to install manually if you are using Mocha.
Running the coverage with Jest...