javascriptreactjsjestjscode-coverage

Difference between statement and line coverage in jest


Can anyone explains me the difference between line coverage and statement coverage in jest. When I ran my coverage report I got a different line coverage percentage compared to statement. enter image description here


Solution

  • if you have a line of code that says var x= 10; console.log(x); that's one line and 2 statements.

    Statement coverage has each statement in the program been executed.

    Line coverage has each executable line in the source file been executed.