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

Report ignored lines? #919

Open naholyr opened 4 years ago

naholyr commented 4 years ago

In this sample code I use /* istanbul ignore if */, which works fine I get to 100% coverage, it's OK. But I'd like to have a way to list all ignored lines, so that later (for example when I have the resources to clear some of those ignored cases) I can identify the "false 100%" and act on them. Today only a global search on /* istanbul can help me and it's not really visual ;)

const LoginForm = ({ logIn, loggedIn, i18n }) => {
  /* istanbul ignore if */
  if (i18n === null) {
    throw new Error('oh no!');
  }
  …

No indication in the file HTML report:

image

And obviously nothing in the listing either, where it would be cool to have a way to add a mention like "100%, 13% ignored":

image

Is there any way to achieve this goal?

sramam commented 4 years ago

I'd like this too.

Wondering if there is a fundamental objection to such a capability?

While I haven't investigated a general double negation, the ignore ability seems to be special cased already, and might be easy enough to double negate.

Thoughts?

(PS: apologies for the multiple edits. I should've finished my cup of coffee before posting!)