I've always used Jasmine for my unit tests, but recently I started using Istanbul to give me code coverage reports. I mean I get the gist of what they are trying to tell me, but I don't really know what each of these percentages represent (Stmts, Branches, Funcs, Lines). So far Googling I have been unable to find a solid explanation/resource.
Question: Like I said I get the gist of it, but can someone post either a proper explanation or a link to a proper explanation?
Tertiary Question: Is there any way to identify what specific parts of your code aren't covered? So far without really grokking this report I'm basically guessing.
-------------------|-----------|-----------|-----------|-----------|
File | % Stmts |% Branches | % Funcs | % Lines |
-------------------|-----------|-----------|-----------|-----------|
controllers/ | 88.1 | 77.78 | 78.57 | 88.1 |
dashboard.js | 88.1 | 77.78 | 78.57 | 88.1 |
-------------------|-----------|-----------|-----------|-----------|
All files | 88.1 | 77.78 | 78.57 | 88.1 |
-------------------|-----------|-----------|-----------|-----------|
There are a number of coverage criteria, the main ones being:
For each case, the percentage represents executed code vs not-executed code, which equals each fraction in percent format (e.g: 50% branches, 1/2).
In the file report:
'E'
stands for 'else path not taken', which means that for the marked if/else statement, the 'if' path has been tested but not the 'else'.'I'
stands for 'if path not taken', which is the opposite case: the 'if' hasn't been tested.xN
in left column is the amount of times that line has been executed.This has been verified for Istanbul v0.4.0, I'm not sure if this still applies for subsequent versions, but being that library is based on solid theoretic principles, behavior shouldn't change too much for newer versions.
It also provides some color codes -
Pink: statements not covered.
Orange: functions not covered.
Yellow: branches not covered.
Full Istanbul docs here:
For more in-depth theory on code coverage:
https://en.wikipedia.org/wiki/Code_coverage
Hope it helps!