CDP-5980: replace nyc with c8 for code coverage#209
Merged
senechko merged 2 commits intoMay 29, 2026
Merged
Conversation
c8 uses V8's native coverage engine instead of Istanbul instrumentation. Keeping ts-node (not switching to tsx) because tsx/esbuild injects helper functions that create phantom uncovered branches in V8 coverage. One c8-ignore pragma on an empty catch body that V8 cannot instrument, plus a new test that exercises the catch path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
c8 and ava depend on yargs@17, which uses require() inside an ESM package. Node 26 rejects this with "ReferenceError: require is not defined in ES module scope". yargs@18 is pure ESM and works on all supported Node versions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mike-engel
approved these changes
May 29, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nycwithc8for code coverage — c8 uses V8's native coverage engine instead of Istanbul instrumentationts-node(not switching totsx) — tsx/esbuild injects helper functions (__name,__export,__copyProps, etc.) that create phantom uncovered branches in V8 coverage, dropping branch coverage to 93% on identical testsc8 ignorepragma on an empty catch body that V8 cannot instrument (the catch is executed by tests, but V8 has no statements to mark as covered)What changed
package.jsonnyc→c8in devDeps and test script;"nyc"config →"c8"config withall: true,src: ["lib"]lib/request.ts/* c8 ignore next 2 */on empty catch block; dropped unusederrbindingtest/request.tsWhy not tsx?
The original plan was to pair c8+tsx (replacing nyc+ts-node). Testing showed tsx is the root cause of the phantom branches reported during the TS6 upgrade attempt:
tsx uses esbuild to transpile, which injects runtime helpers and compiles enums to IIFEs with different branch structure than tsc. V8 coverage counts those as uncovered branches.
Test plan
npm test— 163 tests pass, 100% coverage (statements, branches, functions, lines)npm run lint— clean🤖 Generated with Claude Code
Note
Low Risk
Dev-only coverage tooling and a test plus empty-catch annotation; redirect auth-stripping behavior is unchanged.
Overview
Swaps nyc for c8 (V8-native coverage) while keeping ts-node for tests so coverage stays at 100% branches. The test script runs
c8 ava;package.jsonadds ac8block (all,libas source) and dropsnyc. Lockfile churn reflects removing Istanbul/nyc’s dependency tree and adding c8; anoverridesentry bumps yargs for transitive CLI deps.In
lib/request.ts, redirect header handling is unchanged except the malformed-URL path uses an emptycatch {}with ac8 ignorecomment (V8 can’t mark an empty catch as covered). A new test asserts a redirect with a relativeLocationrejects withTypeError.Reviewed by Cursor Bugbot for commit cd569af. Bugbot is set up for automated code reviews on this repo. Configure here.