istanbul ignore next vs c8 ignore next: every hint, measured
Every ignore hint tried alone in nyc 18 and c8 12: what it skips, and which ones do nothing.

/* istanbul ignore next */ skips the next function or statement, but only in
tools that instrument with Istanbul: nyc, Jest’s default provider, Vitest’s
Istanbul provider. c8 and other V8-based tools read /* c8 ignore next */,
and there “next” means the next line.
Which hints each tool honors
| Hint | nyc 18 | c8 12 |
|---|---|---|
/* istanbul ignore next */ | The whole next function | Nothing |
/* istanbul ignore if */, else | That path of the if | Nothing |
/* istanbul ignore file */ | The whole file | Nothing |
/* istanbul ignore start */ … stop | Nothing | Nothing |
/* c8 ignore next */ | Nothing | One line |
/* c8 ignore next 4 */ | Nothing | Four lines |
/* c8 ignore start */ … stop | Nothing | Every line between |
/* c8 ignore else */, file | Nothing | Nothing |
/* v8 ignore next 4 */ | Nothing | Four lines |

We measured each hint alone on the same file with nyc 18.0.0, c8 12.0.0,
mocha 12.0.3 and Node.js 24. The file has a sign function whose else no
test reaches, and a three-line debugDump function no test calls.
Ignore a function
/* istanbul ignore next */
function debugDump(value) {
const text = JSON.stringify(value);
return text;
}
In nyc this removed the function: 1 of 1 functions and 3 of 4 lines, where the file had 1 of 2 functions and 3 of 6 lines.
In c8 write the line count, or fence the block:
/* c8 ignore start */
function debugDump(value) {
const text = JSON.stringify(value);
return text;
}
/* c8 ignore stop */
Both /* c8 ignore next 4 */ and start / stop took c8 from 10 of 16 lines
to 14 of 16. A bare /* c8 ignore next */ ignored only the function line:
the body stayed uncovered at 11 of 16.

Ignore an else branch
/* istanbul ignore else */
if (x > 0) {
return 'positive';
} else {
return 'other';
}
nyc then reported 1 of 1 branches. ignore if is the opposite: it hides the
path that runs when the condition is true. On this file, where tests only
reach that path, it left 0 of 1 branches.
c8 has no else hint; /* c8 ignore else */ changed nothing. Fence the
else instead:
if (x > 0) {
return 'positive';
/* c8 ignore start */
} else {
return 'other';
}
/* c8 ignore stop */
c8 then reported 3 of 3 branches and every line covered, from 2 of 3 branches.
Why your ignore comment isn’t working
| What we tried | What happened |
|---|---|
istanbul ignore with c8 | Ignored: c8 reads only c8 and v8 hints |
c8 ignore with nyc | Ignored |
c8 ignore next above a function | Only the first line ignored |
istanbul ignore start / stop | Not an Istanbul hint; nothing ignored |
c8 ignore file or c8 ignore else | Not c8 hints; nothing ignored |
In TypeScript, a build step can strip comments before coverage sees them. Vitest 5.1 kept them; see Vitest coverage exclude. For Jest’s two providers, see Jest coverage exclude.
What Supercov adds
npx supercov -- npx mocha test
npx supercov runs latest gaps
Supercov records which test covered each line, with branches and MC/DC. It
does not read ignore comments: the debugDump function above stayed in its
report as not called. To leave a file out, name your source directories
instead. See c8 vs nyc for the two tools side by side.
More coverage guides
- Jest coverageThreshold: global, per-folder and per-file
- JaCoCo aggregate report for multi-module Maven and Gradle builds
- pytest ignore directory: --ignore, norecursedirs and collect_ignore
- Merge coverage reports from shards: Vitest, Jest and coverage.py
- Statement vs branch coverage, with decision, line and path coverage
- JaCoCo report not generated: the causes in Maven and Gradle
- Kover exclude: classes, packages and generated code
- sonar.coverage.exclusions: why SonarQube ignores your JaCoCo excludes
- Go test coverage exclude: files, packages and mocks
- Jest coverage exclude: files, folders and lines
- pytest coverage exclude: omit files, folders and lines
- Vitest coverage exclude: files, folders and lines
- JaCoCo exclude in Maven and Gradle: packages, classes and generated code