gotwarlost / istanbul

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 786 forks source link

Command report changing lcov report on ES6 coverage report #693

Open flamestream opened 8 years ago

flamestream commented 8 years ago

Using

Running

node node_modules/istanbul/lib/cli cover node_modules/mocha/bin/_mocha -- test/a.test.js --compilers js:babel-core/register

and checking coverage/lcov-report/index.html produces correct results.

Then running

node node_modules/istanbul/lib/cli report --root coverage --dir coverage_report text lcov

and checking coverage_report/lcov-report/index.html produces different results. The position of all visual keys seems to be offset in an irregular way.

a.js

function A(params) {

    if (params)
        this.params = params;
}

module.exports = A;

test/a.test.js

var A = require('../a.js');

describe('Invalid input', function() {

    it('No params', function() {

        var a = new A(true);
    });
});
MarshallOfSound commented 8 years ago

@gotwarlost Just wanted to up this issue a bit. I'm facing the same difficulties as @flamestream

Basically all the highlighting in the HTML reports is off by a quite a bit in seemingly random places. I host all my coverage reports online so check out this report as an example.

https://coverage.gpmdp.xyz/feature-react-settings/main/features/core/websocketAPI.js.html

As you can see, some lines are marked as completely covered while still being highlighted red 😢

EDIT: I hacked a fix for this into my code so that linked report looks correct now

MarshallOfSound commented 8 years ago

Some manually editing of the produced HTML files appears to indicate that some of the "span" tags aren't being closed correctly.

Running the HTML through a validator results in quite a few errors like these.

Stray end tag span.
Unclosed element span.
MarshallOfSound commented 8 years ago

Disabling the call to annotateFunctions has fixed this problem for me. Not even sure what annotateFunctions is supposed to affect visually as my coverage report still appears accurate with it disabled 👍

flamestream commented 8 years ago

@MarshallOfSound Thanks for looking for a solution. I've tried to disable that annotateFunctions function call but it didn't seem to have resolved my issue.

Was there anything else that has been modified by any chance? Which version of node/libs do you have running?