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.
Difference between statement and line coverage in jest
Asked Answered
what is the unit coverage in this output? is this the number of lines covered in this repository which is 45.45 % here? –
Sarraceniaceous
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.
This still doesn't make sense. The programming language is free-form. –
Centaury
There can be two statements in one line, but only one statement gets executed
if ({} + [] == 0) || exit(1)
exit(1)
will never occur, because the first statement is always true, and the || operator 'short circuits' the line as soon as the first true is found.
© 2022 - 2024 — McMap. All rights reserved.