Mastering code coverage tooling
When we are building a test suite, we need to make sure that we are covering all the code that is critical in scenarios that make sense for our purpose. This is called code coverage and it’s a very important metric to measure the quality of our test suite.
Some people say that we need to have 100% code coverage, but this is not always true or practical. In my opinion, code coverage is a metric that helps us to detect the code that is not covered by our tests or code that has been over-tested.
Overall, it is a metric that can help us to skim the code and detect potential tests that we need to add or remove.
Configuration
Historically, code coverage was a feature that was provided by third-party libraries such as Istanbul (https://istanbul.js.org/). But now, Node.js and Jest provide this feature out of the box, so we don’t need to install any third-party library.
Jest library
Let’s add the following npm script to...