Skip to content

Coverage report is missing uncovered files when using --all with --include #588

Open

Description

@wellwelwel

When running the test suite of MySQL2 with c8 using --all combined with --include, some files that exist and match the include patterns become invisible in the coverage report when totally uncovered.

For context, here is the coverage configuration used:

{
  "all": true,
  "include": ["index.js", "promise.js", "lib/**/*.js"],
  "exclude": ["mysqldata/**", "node_modules/**", "test/**"],
  "reporter": ["text", "lcov", "cobertura"],
  "statements": 80,
  "branches": 80,
  "functions": 77,
  "lines": 80,
  "checkCoverage": true,
  "clean": true
}

However, lib/results_stream.js and lib/packets/binlog_query_statusvars.js don't appear in the report.

Expected behavior:

When bypassing c8's filtering (e.g., collecting V8 coverage data directly and calling Report programmatically) from my custom plugin that uses C8 behind the scenes, both files correctly appear with 0% coverage, confirming they exist and match the patterns.

Note

  • I'm preparing a fix for this 🙋🏻‍♂️

Activity

  1. JBallin commented on Oct 11, 2026

    @JBallin

    I found another case that #589 fixes: with --all, c8 adds empty coverage for an executed file when its coverage entry uses an absolute path instead of a file:// URL. I reproduced this with c8 12.0.0 and verified that #589 handles both formats correctly. Could the absolute-path case be included in the regression tests?

    Runnable reproduction

    Save this as repro.cjs in an isolated directory with c8 available, then run node repro.cjs:

    const fs = require('node:fs');
    const path = require('node:path');
    const { pathToFileURL } = require('node:url');
    const createReport = require('c8/lib/report.js');
    
    const source = 'function answer() { return 42; }\nanswer();\n';
    const filename = path.resolve('subject.cjs');
    fs.writeFileSync(filename, source);
    
    for (const kind of ['absolute', 'file-url']) {
      const report = createReport({
        all: true, src: [process.cwd()],
        include: ['subject.cjs'], exclude: [], extension: ['.cjs']
      });
      const index = new Set();
      const normalized = report._normalizeProcessCov({
        result: [{
          scriptId: '1',
          url: kind === 'absolute' ? filename : pathToFileURL(filename).href,
          functions: [{
            functionName: '', isBlockCoverage: true,
            ranges: [{ startOffset: 0, endOffset: source.length, count: 1 }]
          }]
        }]
      }, index);
      console.log(kind, JSON.stringify({
        accepted: normalized.result.length,
        indexed: index.has(filename),
        emptyReports: report._includeUncoveredFiles(index).length
      }));
    }

    Actual output with c8 12.0.0:

    absolute {"accepted":1,"indexed":false,"emptyReports":1}
    file-url {"accepted":1,"indexed":true,"emptyReports":0}
    

    Expected: both accepted identities should be indexed, with zero empty reports for this executed file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions