Skip to content

chore: Replace nyc with c8 for coverage - #163

Open
TwitchBronBron wants to merge 2 commits into
masterfrom
chore/nyc-to-c8
Open

TwitchBronBron wants to merge 2 commits into
masterfrom
chore/nyc-to-c8

Conversation

@TwitchBronBron

@TwitchBronBron TwitchBronBron commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

nyc@15 hasn't been updated in years and pulled ~100 transitive packages, including deprecated glob@7/rimraf@3 and istanbul-lib-processinfo — which we were patching via overrides. c8 uses V8's native coverage instead.

Pinned to c8@10, the last line supporting Node 18 (c8@12 requires >=20.19). Verified on Node 18.20.8 locally; CI is on 18.20.4.

What changed

  • 429 → 366 total packages
  • Dropped the istanbul-lib-processinfo, uuid, and @babel/core overrides (all nyc-only). This also clears every EBADENGINE warning on Node 18 — two of those overrides required Node ≥20.
  • Converted the 4 istanbul ignore pragmas to c8 ignore; c8 doesn't honor istanbul's. Same unreachable defensive branches as before, not newly-waived code.
  • Removed test:nocover. It existed because nyc mangled stack-trace line numbers. Measured against master's actual nyc config with a probe file of known-line failures, 4 of 5 frames were wrong — worst was util.ts:6:212 for code on line 13, a column that exists on no line of that file (nyc was mapping to its instrumented output). c8 matches the no-coverage run exactly on all 5 frames, so the separate script has no remaining purpose. Overhead is ~0.8s (2.7s → 3.5s). The VSCode test task now runs npm test; launch.json invokes _mocha directly and needed no change.
  • Coveralls still reads ./coverage/lcov.info — unchanged path, lcovonly reporter retained along with text-summary and html. The HTML report renders TypeScript source, so mapping works there too.
  • Also fixes 2 pre-existing lint errors (logical-assignment-operators) surfaced by the eslint 8.16→8.57 bump in the refreshed lockfile. They reproduce on master and would block CI regardless.

One caveat worth knowing: c8@10 is a frozen line until the Node 18 floor moves, so this trades nyc's staleness for a pin rather than eliminating it. The tree reduction, override cleanup, and correct sourcemaps are the real wins.

Verified: 324 tests passing at 100% statements/branches/functions/lines after a clean rm -rf node_modules package-lock.json && npm install; npm run lint, npm run build, and npm run audit (0 vulnerabilities) all clean. Also confirmed the coverage gate still fails correctly by temporarily adding an uncovered function — exit code 1, all three affected metrics flagged.

🤖 Generated with Claude Code

nyc@15 hasn't been updated in years and dragged in ~100 transitive packages,
including deprecated glob@7/rimraf@3 and istanbul-lib-processinfo, which we
were patching via overrides. c8 uses V8's native coverage instead.

Pinned to c8@10, the last line supporting Node 18 (c8@12 requires >=20.19).

- 429 -> 366 total packages
- Dropped the istanbul-lib-processinfo, uuid, and @babel/core overrides
  (all nyc-only), which also clears every EBADENGINE warning on Node 18
- Converted the 4 `istanbul ignore` pragmas to `c8 ignore`; c8 doesn't honor
  istanbul's. These are the same unreachable defensive branches as before,
  not newly-waived code.
- Coveralls still reads ./coverage/lcov.info, unchanged

Also fixes 2 pre-existing lint errors surfaced by the eslint 8.16->8.57 bump
in the refreshed lockfile (logical-assignment-operators).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@TwitchBronBron
TwitchBronBron marked this pull request as draft September 10, 2026 16:21
test:nocover existed because nyc reported wrong line numbers in stack traces.
Verified against master's actual nyc config: 4 of 5 stack frames were wrong,
including util.ts:6:212 for code on line 13 (a column that doesn't exist on
any line of that file) - nyc was mapping to its instrumented output.

c8 matches the no-coverage run exactly on all 5 frames, so the separate
script no longer serves a purpose. Overhead is ~0.8s (2.7s -> 3.5s).

Repointed the VSCode test task at `npm test`. launch.json invokes _mocha
directly and needed no change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@TwitchBronBron
TwitchBronBron marked this pull request as ready for review September 10, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant