Skip to content
Latchkey

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.

nyc
WARN: No coverage information was collected, exit without writing coverage information

Common 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.

Terminal
vitest run --coverage         # use the runner's own coverage
# or jest --coverage

Fix include/exclude so files are instrumented

  1. Confirm include matches real source paths relative to the project root.
  2. Loosen exclude so it does not remove everything.
  3. Re-run and confirm a non-empty report is written.
.nycrc.json
// .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 include globs against the actual source layout.
  • Avoid excludes that match every file.

Frequently asked questions

What causes ""No coverage information was collected""?
Modern runners (Vitest, Jest, ESM) collect coverage themselves; wrapping them in nyc instruments the wrong process, so nyc sees nothing.
How do I fix "No coverage information was collected"?
For Vitest or Jest, enable their built-in coverage instead of wrapping the command in nyc.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card