nyc "No coverage information was collected" in CI
nyc wrapped the test command but no coverage data came back: it instrumented no files, the test runner spawned a child process nyc did not instrument, or the process exited before coverage was flushed.
What this error means
nyc warns "No coverage information was collected, exit without writing coverage information" and produces an empty or missing report.
WARN: No coverage information was collected, exit without writing coverage informationCommon causes
nyc instruments a different process than the tests run in
Modern runners (Vitest, Jest, ESM) collect coverage themselves; wrapping them in nyc instruments the wrong process, so nyc sees nothing.
No source files matched include, or all were excluded
An include that matches nothing, or an over-broad exclude, leaves nyc with no instrumented files to report.
How to fix it
Use the runner's native coverage, not nyc, where appropriate
For Vitest or Jest, enable their built-in coverage instead of wrapping the command in nyc.
vitest run --coverage # use the runner's own coverage
# or jest --coverageFix include/exclude so files are instrumented
- Confirm
includematches real source paths relative to the project root. - Loosen
excludeso it does not remove everything. - Re-run and confirm a non-empty report is written.
// .nycrc.json
{ "include": ["src/**/*.js"], "exclude": ["**/*.test.js"] }How to prevent it
- Match coverage tooling to the test runner (nyc for plain Node, native for Vitest/Jest).
- Verify
includeglobs against the actual source layout. - Avoid excludes that match every file.