Determining Code Coverage

Learn how to determine code coverage to identify missing tests from a test suite in this lesson.

Understanding code coverage

Code coverage defines the amount of source code covered by tests. It allows us to identify gaps in our test suite quickly.

Jest gives us the following coverage statistics for each source file:

  • Statement coverage: How many of the source code statements have been executed during test execution?

  • Branch coverage: How many of the branches of conditional logic (for example,. branches in an if statement) have been executed during test execution?

  • Function coverage: How many of the functions have been called during test execution?

  • Line coverage: How many lines of source code have been executed during test execution?

Get hands-on with 1200+ tech skills courses.