What does /* istanbul ignore next */ do?

nick asked this question 10 months ago
nick on Mar 23, 2022

I'm reading someone else's JavaScript code and came across this line of code:

/* istanbul ignore next */

What does this line of code do?

2 suggested answers
looper003 on May 12, 2022

istanbul is a JavaScript code coverage tool.

Some things are hard to test, so /* istanbul ignore next */ tells istanbul to skip and not include the next thing in your source code when calculating code coverage for your project.

0 replies
coderguy on May 12, 2022

It's a way to exclude code in your project in code coverage reports.

More info here: github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md.

0 replies