Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 872
Roopak PutheVeettil Avatar asked Jan 21 '20 17:01

Roopak PutheVeettil


People also ask

Is statement coverage the same as line coverage?

Relation to other metrics100% Statement Coverage implies 100% Line Coverage. But the opposite is not true: a line may contain multiple statements whereas a test may not succeed in executing all of them.

What is the difference between a line and a line statement?

Line of code is basically how many end points you are using. A Statement is the group of code that you produce to create an expected output.

What is the difference between line coverage and branch coverage?

Line coverage measures how many statements you took (a statement is usually a line of code, not including comments, conditionals, etc). Branch coverages checks if you took the true and false branch for each conditional (if, while, for).

What is line coverage in code coverage?

Line coverage reports on the execution footprint of testing in terms of which lines of code were executed to complete the test. Edge coverage reports which branches or code decision points were executed to complete the test. They both report a coverage metric, measured as a percentage.


1 Answers

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.

like image 134
Aldrin Avatar answered Sep 22 '22 07:09

Aldrin