Jest's types of test coverage
Play this article
Have you ever ran Jest tests and got these following outputs, wondering which type of coverage to use?
Below is a definition for each type:
- Function coverage: Has each function (or subroutine) in the program been called?
- Statement coverage: Has each statement in the program been executed?
- Branch coverage: Has each branch (also called DD-path) of each control structure (such as in if and case statements) been executed? For example, given an if statement, have both the true and false branches been executed? Another way of saying this is, has every edge in the program been executed?
- Line coverage: has each executable line in the source file been executed?