Skip to content

CLI: the coverage map drops files a test reads by a relative path #191

Closed

Description

@FredApps

What went wrong?

DiffCI left out a test that should have run (a miss): the coverage map does not record files a test reads by a relative path.

DiffCI version

0.3.54 (main at 40aa308)

Command you ran

diffci coverage --command "node --test test/data.test.cjs"

Environment

Ubuntu, Node.js 24.22.1, npm, terminal.

What happens

The coverage map probe in packages/diffci-cli/src/client/coverage-map.ts records the path argument of fs.readFileSync, fs.readdirSync and the other wrapped calls exactly as the test passed it. buildCoverageMap then keeps only absolute paths (inRepo returns undefined for anything !isAbsolute). A test that reads a fixture relative to its working directory, which is the repository root under node --test, therefore gets no map entry for that fixture, and verify cannot add the test when the fixture changes.

Reproduction:

git init -q repro && cd repro
mkdir -p test fixtures
echo '{"x":1}' > fixtures/rel.json
echo '{"y":2}' > fixtures/abs.json
cat > test/data.test.cjs <<'JS'
const test = require("node:test");
const fs = require("node:fs");
const path = require("node:path");
test("reads fixtures", () => {
  fs.readFileSync("fixtures/rel.json", "utf8");
  fs.readFileSync(path.join(__dirname, "..", "fixtures", "abs.json"), "utf8");
});
JS
echo '{"name":"p","private":true,"scripts":{"test":"node --test test/"}}' > package.json
git add -A && git commit -qm init
diffci coverage --command "node --test test/data.test.cjs"
cat .git/diffci/coverage-map.json

Output:

{"schema":"diffci.coverage-map.v1",...,"tests":{"test/data.test.cjs":["fixtures/abs.json"]}}

fixtures/rel.json is missing, although the test read it. The same happens for a directory listed with a relative path (readdirSync("locales")).

What you expected

"test/data.test.cjs": ["fixtures/abs.json", "fixtures/rel.json"]. The probe should resolve a relative path against the test process's working directory at the time of the call, as fs itself does.

Regression test

A new test in packages/diffci-cli/tests/client/coverage-map.test.ts in the linked pull request fails on main and passes with the fix.

Activity

  1. added a commit that references this issue on Nov 18, 2026
    cac9541
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions