Generate Test Coverage Report
Explore how to generate and use coverage reports using Jest.
Test coverage is a metric that indicates the percentage of our codebase covered by tests. In this lesson, we’ll explore the concept of test coverage and learn how to generate the coverage report using Jest.
Overview
Test coverage is determined by checking how much of the code in a project is tested by the unit tests. The process involves dividing the number of lines or branches covered by tests by the codebase’s total number of lines or branches. For example, if a unit test suite covers 80 out of 100 lines of code, the test coverage would be 80%.
Test coverage assesses how thoroughly the automated tests explore different paths within the code. This measurement helps pinpoint areas that might lack sufficient testing. It serves as a metric to gauge the effectiveness of testing efforts, reducing the risk of undetected defects and improving the overall reliability of the project.
How much test coverage should we aim for?
Get hands-on with 1400+ tech skills courses.