Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k
stars
787
forks
source link
Cannot get report for non-covered parts of conditions #784
// util.js file
function deneme(a) {
return (a && a.startsWith('a')) ? true : false;
}
module.exports = {
deneme
};
Although two branches are executed by tests and as a result tests seem to cover 100% of the code, second part of the condition is never tested/executed.
lab reported that first part of the condition a is always true, so that second part a.startWith('a') is never executed. Please see screenshot below:
Hi,
I use
mocha
&istanbul
for some projects andlab
for some others.For the very simplified example below
istanbul
reported 100% coverage whereaslab
reported less than 100%.Istanbul
$ istanbul cover _mocha
Lab
$ lab --coverage --reporter html > report.html
Function
Although two branches are executed by tests and as a result tests seem to cover 100% of the code, second part of the condition is never tested/executed.
lab
reported that first part of the conditiona
is always true, so that second parta.startWith('a')
is never executed. Please see screenshot below:A third test should be added for this case:
Not in this simple example, but in more complex situations it helped me hunt some hard to catch bugs.
Is it possible to detect condition coverage in
Istanbul
?Kind Regards,