Ts-jest: Istanbul ignore statements not being respected

Created on 27 Sep 2017  路  20Comments  路  Source: kulshekhar/ts-jest

  • Issue

/* istanbul ignore next */ statements are not being respected in files, even with removeComments: false set in tsconfig.json

  • Expected behavior
function* infiniteCounter() {
  let i = 0;
  /* istanbul ignore next */
  while(true) { // <-- coverage should be ignored here
    yield i;
    i++;
  }
} 

Related:

Most helpful comment

Same problem here. Flipping my removeComments did not change anything with versions:

jest: 22.4.3
ts-jest: 22.4.2

All 20 comments

ts-jest doesn't handle coverage at all so I can't put a finger right away on what might be going wrong.

Can you create a minimal repo that demonstrates this issue? It'll help debug and, if the problem is in ts-jest, fix the issue.

@kulshekhar Sure thing. I'll see if I can get to that sometime tomorrow afternoon (USA EST)

@dsifford is this something jest handles correctly that we're breaking in ts-jest?

@kulshekhar Let's put this on hold.. Just made a minimal duplicate of my issue and for whatever reason I can't get it to error. So something fishy must be happening on my end.

I'll reopen if necessary once I figure out what the heck is going on.

I had a similar issue. But then I noticed that I had removeComments set to false in my tsconfig.json file. Switching it to true got rid of the issue for me.

I am also experiencing the same issue with istanbul comments not being respected in coverage reports. removeComments in tsconfig.json didn't seem to have any effect.

I'm using jest 21.2.1 and ts-jest 21.1.2

Feel free to provide a minimal repo where it errors on typescript but not on regular jest.

As we don't handle coverage, I have a sneaking suspicion that it's not an issue on our end.

Changing the removeComments to false fixed it for me. All we need is for ts-jest to override that option to be true. I had a go at doing that but overriding it in the preprocessor doesn't seem to work.

Same problem here. Flipping my removeComments did not change anything with versions:

jest: 22.4.3
ts-jest: 22.4.2

This also happens to me.
ts-jest: 22.4.2
jest: 22.4.2

Same problem here. Flipping my removeComments did not change anything with versions:

ts-jest: 22.4.6
jest: 22.4.4

@kaskar2008 you should update both jest and ts-jest

Also happening to me
[email protected]
[email protected]

@jbccollins please open a new issue and provide a link to a minimal repo where we can reproduce your issue, so that we can fix it then ;-)

Same for me
"jest": "~24.7.1",
"ts-jest": "^24.0.2",

Can we reopen it?

"jest": "^24.7.1", "ts-jest": "^24.0.2",

Solution is
// istanbul ignore next

No it isn't @dfa1234

It appears because TS also makes transpilation according to compilerOptions:target. So you need tsconfig.test.json with target: es6 for null coalesce and other stuff, tsconfig.build.json for project with target: es3. Until istanbul has no command like /* ignore start */ ... /* ignore end */ we cannot ignore optional chaining

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RiJung picture RiJung  路  4Comments

Vinnl picture Vinnl  路  3Comments

mikeyakymenko picture mikeyakymenko  路  3Comments

japhar81 picture japhar81  路  3Comments

remcohaszing picture remcohaszing  路  4Comments