Bryan Lemon
Bryan Lemon

Reputation: 61

IstanbulJS code coverage shows 100% line coverage but <100% statement coverage

I am using Mocha for my test runner, and nyc for the test reporter. I don't see any uncovered lines and was wondering if anyone knows how can be uncovered functions and statements, while every line is covered. Ideas?

--------------------|----------|----------|----------|----------|----------------|
File                |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
--------------------|----------|----------|----------|----------|----------------|
  file.js           |    98.77 |      100 |    88.89 |      100 |                |

Upvotes: 4

Views: 1824

Answers (1)

Bryan Lemon
Bryan Lemon

Reputation: 61

Leonardo Venoso pointed me in the right direction on this.

Running

nyc --reporter=html --reporter=text npm test

gave me a file located in ./coverage that highlighted the exact code that wasn't covered.

It was a line similar to

let data = arr.sort((a,b) => a.compareTo(b));

(a,b) => a.compareTo(b) was never called because arr had a length of 1.

Upvotes: 2

Related Questions