

Personally, I'm not fixated in 100% code coverage, but in the projects I work on I always strive for at least a 90%-95% of coverage. What we are interested in, most of the time, is also a good amount of code coverage in unit testing. Configuring a coverage thresholdĬode coverage is nothing by itself. We will see an example minimal configuration at the end of this post.

Key takeaway: always pass -collectCoverageFrom and -coverage to Jest from the command line, or configure collectCoverage and collectCoverageFrom in your Jest config.

Now Jest is identify correctly what needs to be tested. By running the above command we can see the following output: Npm test -coverage -collectCoverageFrom = "./src/**"īy doing so we say to Jest to look in the whole src folder for JavaScript files.
