question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

istanbul-ignore-file comments getting ignored

See original GitHub issue

Issue :

When using babel, istanbul-ignore-file comments are ignored and the files are included in coverage. setting useBabelrc: false gives the desired outcome.

The repo I’m providing tests both .ts and .js because I wasn’t sure if the issue was ts-jest or some other factor. For the js files I was able to get jest to respect the istanbul comments by trying a different preset: @babel/preset-env instead of the metro-react-native-babel-preset I need for react native. For the ts files the istanbul comments are ignored regardless. I wonder if there’s some common reason?

Expected behavior :

Files with /* istanbul ignore file */ should be omitted from coverage reports.

Minimal repo :

https://github.com/donovanhiland/ignoring-istanbul-ignore-file

Possibly related issue opened here: https://github.com/facebook/metro/issues/360

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

2reactions
jbolotincommented, Mar 21, 2020

Reproducible on ts-jest 25.2.1 and jest 25.1.0

Update: This doesn’t seem to be a ts-jest problem, or at least, I can no longer reproduce this issue with the above versions. The problem apparently was that an empty line is needed below this comment at the top of the file. This is poorly documented by istanbul, but ts-jest should be good here. It should be safe to close this issue now

1reaction
httpetecommented, Jan 6, 2022

In my case the pragmas wouldn’t work unless I had:

coverageProvider: ‘babel’

in my jest.config.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

"istanbul ignore next" command seems to be ignored
It was working quite fine until I tried to exclude a class method from the tests. But the test keeps failing and the...
Read more >
Sonar doesn't respect istanbul ignore comments - SonarCloud
The only option today is to duplicate the “istanbul” information to the property sonar.coverage.exclusions by listing all the files you expect ...
Read more >
Istanbul | Best of JS
Istanbul. Code coverage tool that computes statement, line, function and branch coverage ... It will also exclude any files with the extension .spec.js...
Read more >
Istanbul Ignore Syntax for Jest Code Coverage
This is done with special comments which are parsed by Istanbul. There are a few variations ... istanbul ignore file */ ... file...
Read more >
How to ignore some statements in Javascript code coverage ...
(see https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md) ... The only thing that's available regarding comments is //NOSONAR, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found