Skip to content

test: set up test coverage with c8 - #563

Open
caugner wants to merge 1 commit into
mainfrom
setup-c8-coverage
Open

test: set up test coverage with c8#563
caugner wants to merge 1 commit into
mainfrom
setup-c8-coverage

Conversation

@caugner

@caugner caugner commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Set up test coverage with c8:

  • Add a test:coverage script that wraps the existing npm test command with c8.
  • Run test:coverage in the CI test job so missing coverage is easy to spot.
  • Configure c8 via .c8rc.json with all: true (so source files with no coverage at all are still reported) and excludes for eslint.config.js, coverage/, node_modules/, and test/.
  • Ignore the generated coverage/ directory in git and Prettier. ESLint already ignores it via .gitignore (includeIgnoreFile).

Motivation

Make it easy to identify missing test coverage.

Additional details

c8 uses its default text reporter, printing a coverage summary at the end of the test run.

Unlike mdn/dex#263, the test exclude is test/** rather than **/*.test.js, because this repo keeps test helpers (test/helpers.js, test/helpers/db.js) alongside the *.test.js files.

Related issues and pull requests

Similar to mdn/dex#263.

Add a `test:coverage` script that wraps the existing test command with
`c8`, and run it in CI so missing coverage is easy to spot. `all: true`
surfaces source files with no coverage at all.

Ignore the generated `coverage/` directory in git and Prettier; ESLint
already ignores it via `.gitignore`.
@caugner
caugner force-pushed the setup-c8-coverage branch from 079f7ef to 600260a Compare July 15, 2026 21:52
@caugner
caugner marked this pull request as ready for review July 15, 2026 21:52
@caugner
caugner requested review from a team and mdn-bot as code owners July 15, 2026 21:52
@caugner
caugner requested a review from LeoMcA July 15, 2026 21:52
@caugner caugner changed the title chore(test): set up test coverage with c8 test: set up test coverage with c8 Jul 15, 2026
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