Skip to content
This repository has been archived by the owner on Dec 31, 2019. It is now read-only.

Ignoring Statements, Branches, etc.? #86

Open
jednano opened this issue Nov 6, 2015 · 3 comments
Open

Ignoring Statements, Branches, etc.? #86

jednano opened this issue Nov 6, 2015 · 3 comments

Comments

@jednano
Copy link
Contributor

jednano commented Nov 6, 2015

@nathancahill and I are seeing statements and branches ignored, even though there are no ignore comments in our source code. It looks like this:

=============================== Coverage summary ===============================
Statements   : 100% ( 138/138 ), 10 ignored
Branches     : 98.61% ( 71/72 ), 9 ignored
Functions    : 100% ( 12/12 )
Lines        : 100% ( 69/69 )
================================================================================

Any idea why code is being ignored for seemingly no reason? Or maybe the report is off somehow?

@jamesplease
Copy link

@jedmao, in my tests it appeared to me that isparta was reporting inconsistent stats. Let me explain.

When you compile your source code, you end up with two versions of the same file: the original, and the compiled version.

The compiled version is usually more verbose and messy than the original version.

After using isparta, you will get data on Lines for the original file. Because of this, the "visualizer" that displays the lines covered can show the original source.

However, every other data point will reference the compiled code. What you're seeing here is likely due to Babel adding an internal function with a few branches that your tests aren't fully covering.

You can see this by running babel my-file.js --out-file build.js and comparing what the stats are reporting to your original and compiled code. You might even be able to step through and figure out which branch is being missed in the compiled version.

So is it fixable? I'm not sure, honestly. I know very little about the internals of isparta and Istanbul.

As for me, I don't worry too much about the mismatch. I use code coverage to get an approximation of how complete my tests are. Even a value of 100% on everything doesn't mean that the code has no bugs.

Anyway, I don't think I'll convince anyone to change their opinion on whether or not 100% code coverage matters, but it's worth keeping in mind that the coverage data will partially reflect the transpiled code.

Does that make sense?

@jednano
Copy link
Contributor Author

jednano commented Dec 29, 2015

@jmeas yeah that makes sense, but it's still not ideal. I wonder if isparta could more gracefully report what's going on instead of saying "skipped" for babel-generated code. Until then, I'm forced to "ignore" the number of ignored statements and branches, trusting that it's indeed accurate. Again, not ideal. Still waiting to hear back from @douglasduteil.

@HipsterZipster
Copy link

HipsterZipster commented Aug 12, 2016

This still seems to be happening in the latest version of isparta ^4.0.0
@jedmao Were you ever able to get around it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants