Skip to content
Latchkey

nyc/c8 "No coverage information" - Source Maps & Instrumentation in CI

nyc/c8 reports no coverage (or 0%) because the code that ran was never instrumented or mapped back to source. Usually the test process that actually executes your code is a child nyc did not wrap, or the include/exclude globs miss your files.

What this error means

A coverage run prints "No coverage information was collected" or shows 0% for files you know were exercised. Tests pass; only the coverage numbers are empty, pointing at instrumentation, not the tests.

nyc/c8 output
=============================== Coverage summary ===============================
Statements   : 0% ( 0/0 )
================================================================================
WARN: No coverage information was collected, exit without writing coverage

Common causes

The instrumented process is not the one running code

nyc wraps the command it launches, but if your runner spawns a separate child (or you run the compiled dist while including src), the executed code is outside nyc’s instrumentation.

Wrong include/exclude or missing source maps

An include glob that does not match your files, or transpiled code without source maps, means c8 cannot attribute V8 coverage back to your TypeScript/source.

How to fix it

Instrument the real process and configure globs

For c8 (V8-based), enable source maps and set include/exclude to your source layout.

.c8rc.json
// .c8rc.json
{
  "all": true,
  "src": ["src"],
  "include": ["src/**/*.ts"],
  "exclude": ["**/*.test.ts", "dist/**"],
  "reporter": ["text", "lcov"]
}

Make sure coverage follows child processes

  1. Run the test command under c8/nyc directly (c8 vitest run), not a wrapper that spawns an uninstrumented child.
  2. Emit source maps from your TS/Babel build so coverage maps to source.
  3. Verify the include glob matches the files you expect (run with --all to see uncovered ones).

How to prevent it

  • Run the test runner under c8/nyc so the executing process is instrumented.
  • Enable source maps for transpiled code.
  • Keep include/exclude globs aligned with your source layout.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →