Skip to content

fix(T13874): minCount reads the JSON report vitest 5 announces - #2360

Open
kryptobaseddev wants to merge 2 commits into
mainfrom
fix/T13874-report-cwd
Open

kryptobaseddev wants to merge 2 commits into
mainfrom
fix/T13874-report-cwd

Conversation

@kryptobaseddev

Copy link
Copy Markdown
Owner

Fixes T13874, the T13782 regression that blocks VidaPeps T2018 to T2022 and T781 on 10.19.

Root cause

I read vitest 5.0.4's JSON reporter in VidaPeps' installed lib/db/node_modules/vitest, file dist/chunks/cli-api.*.js. With --reporter=json and no outputFile, vitest 5 no longer writes the report to stdout. It writes .vitest/json/output.json under its own config root and then prints JSON report written to <absolute path>.

The gate command is pnpm --filter @workspace/db exec vitest …, so the root is lib/db, not the project root. VidaPeps' report is sitting at lib/db/.vitest/json/output.json: 9 tests, all passed, and it satisfies testCountReportSchema. CLEO only looked at <projectRoot>/.vitest/json/output.json, so every minCount gate failed with "emitted no machine-readable test report".

I ruled out two other suspects:

  • pnpm passes everything after exec straight through (escapeArgs), so vitest does receive --reporter=json.
  • A filtered exec inherits stdio by default, so nothing wraps the output.

Fix

runTestGate now also reads every report path the run announces with vitest's JSON report written to <path> line. Only paths inside the project are read. These paths have no pre-spawn stamp, so the freshness rule still applies: the file's mtime and the report's startTime must both be at or after the spawn.

Tests

Three new cases in packages/core/src/tasks/__tests__/gate-runner.test.ts. Each uses a fake runner that chdirs into lib/db, writes .vitest/json/output.json there and prints vitest's announce line:

  • the report is read and the gate passes
  • red: an announced report whose startTime predates the run is refused
  • red: an announced report outside the project is never read

Not run locally: owner directive, no local heavy runs. CI runs them, along with tsc and the build. Locally I ran biome on both changed files, gate 32 (--base origin/main) and gate 38 (--base origin/main), all OK. The changeset is validated only by CI's Changeset Lint.

🤖 Generated with Claude Code

kryptobaseddev and others added 2 commits October 17, 2026 12:49
vitest 5 with --reporter=json and no outputFile writes
.vitest/json/output.json under its own root (the child's cwd) and prints
'JSON report written to <path>'. Behind pnpm --filter <pkg> exec that is
the package, not the project root, so every minCount gate failed with
'emitted no machine-readable test report' (VidaPeps T2018-T2022, T781).
The gate now also reads the path the run announces, inside the project
only, under the same freshness rules (mtime and startTime postdate the
spawn).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ement counts

Containment was lexical while stat/readFile follow symlinks, so an
in-project symlink to a fresh file outside the project was read. Both the
announced path and the project root are now realpathed first. Only the
last 'JSON report written to' line counts (vitest prints it at the end),
so a test's earlier fabricated line cannot stand in for it. Also fixes
the T13874 fake runner, which redeclared p/t and could not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant