Skip to content

chore(test): setup test coverage with c8#263

Open
caugner wants to merge 6 commits intomainfrom
test-coverage
Open

chore(test): setup test coverage with c8#263
caugner wants to merge 6 commits intomainfrom
test-coverage

Conversation

@caugner
Copy link
Contributor

@caugner caugner commented Mar 17, 2026

Description

Sets up test coverage with c8, and adds a test:coverage script.

Motivation

Make it easy to identify missing test coverage.

Additional details

See this test job run to see how it looks.

Reasons for using c8 instead of experimental Node-native coverage reporters:

  • c8 allows defining file excludes
  • c8 allows excluding parts of files (see this GitHub search in BCD)
  • c8 creates multiple reports simultaneously (1. text summary, 2. lcov.info, 3. index.html with visual), whereas you'd need to run node --test twice to get both
  • c8 includes files without any coverage, whereas node --experimental-test-coverage omits these (see Report 0% coverage for untested files in a project (i.e., files matching some glob) nodejs/node#58887)
  • performance is comparable:
    node --test --experimental-test-coverage  0.92s user 0.18s system 100% cpu 1.091 total
    node --test --experimental-test-coverage --test-reporter=lcov   0.93s user 0.11s system 148% cpu 0.702 total
    npx c8 node --test  0.98s user 0.21s system 112% cpu 1.053 total
    

Related issues and pull requests

@caugner caugner requested review from a team and mdn-bot as code owners March 17, 2026 16:37
@caugner caugner requested a review from LeoMcA March 17, 2026 16:37
@caugner caugner marked this pull request as ready for review March 17, 2026 17:01
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.

2 participants