douglasduteil / isparta

:skull: A code coverage tool for ES6 (babel/6to5)
Do What The F*ck You Want To Public License
642 stars 47 forks source link

Shows code as covered which is obviously not covered #99

Open gearsdigital opened 8 years ago

gearsdigital commented 8 years ago

Currently I'm running into an issue described here. https://github.com/karma-runner/karma-coverage/issues/185. I'm quite unsure if this is related to isparta, istanbul or my-brain. Maybe i miss something?

Let me explain what's going on. I've a simple library, written in ES6, which i want to test.

Example code: https://github.com/gearsdigital/stunning-octo-train

Given

// src/utilities.js
export function objectLength(obj) {
    return Object.keys(obj).length;
}

Spec

// test/utilities-spec.js
import {objectLength} from '../src/utilities';
describe('utilities', function () { });

Expected Result

The generated coverage report looks fine so far:

report

Unexpected Result

If i want to reuse the method written above and execute it, the overage report looks wrong for me. There are no tests for this method.

report2

I wrote about the same problem here: http://stackoverflow.com/questions/34291595/karma-coverage-report-shows-code-as-covered-which-is-obviously-not-covered