rtk vitest reports a failing run as green: suite-level failures dropped from the summary
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 81.1k
- Forks
- 5.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 35
Description
Summary
rtk vitest reports a failing run as fully green. When a test file fails to collect (import error, syntax error, failed top-level beforeAll), vitest counts it as a failed suite, not a failed test. RTK's summary reads only the test counts and ignores the suite counts, so the failure disappears from the output.
The exit code is correct (1), so the run is not silently green — but the human- and LLM-readable summary says FAIL (0), which is the opposite of the truth.
Reproduction
mkdir rtk-vitest-repro && cd rtk-vitest-repro
cat > package.json <<'JSON'
{ "name": "rtk-vitest-repro", "private": true, "type": "module",
"devDependencies": { "vitest": "^2.1.0" } }
JSON
mkdir test
cat > test/passing.test.js <<'JS'
import { test, expect } from 'vitest'
test('a', () => { expect(1).toBe(1) })
test('b', () => { expect(2).toBe(2) })
JS
cat > test/broken.test.js <<'JS'
import { thing } from './does-not-exist.js' // fails to collect
import { test } from 'vitest'
test('never runs', () => { thing() })
JS
npm install
Actual vs expected
| Test Files | Tests | Exit | |
|---|---|---|---|
npx vitest run (ground truth) |
1 failed | 1 passed (2) | 2 passed (2) | 1 |
rtk vitest run |
not reported | PASS (2) FAIL (0) |
1 |
$ rtk vitest run
PASS (2) FAIL (0)
[full output: "$HOME/Library/Application Support/rtk/tee/<ts>_vitest_run.log"]
PASS (2) FAIL (0) reads as a clean green run. The file that failed to collect is absent.
RTK has the correct numbers and drops them
RTK invokes vitest with a JSON reporter. Parsed from the tee log it wrote:
{
"numTotalTestSuites": 2,
"numPassedTestSuites": 1,
"numFailedTestSuites": 1,
"numTotalTests": 2,
"numPassedTests": 2,
"numFailedTests": 0,
"success": false
}
numFailedTestSuites: 1 and success: false are both present and both ignored. The summary is derived from numPassedTests / numFailedTests only.
Secondary issue: the tee log is not a recovery path here
The tee log contains the raw JSON but not vitest's own Test Files / Tests summary lines (verified: 'Test Files' in log == False). So a user who notices the exit code and opens the log still does not get the readable summary back. For comparison, rtk grep's tee log does contain the full original output, which is the behaviour I'd expect.
Suggested fix
Include suite-level failures in the summary, and prefer the reporter's own success field over a count comparison. Something like:
PASS (2) FAIL (0) SUITES 1 failed
or simply refuse to print a green-looking summary when success: false.
Why this matters
This is a real, reproducible case where an agent reading RTK's output concludes a test suite passed when it did not. On a real project (45 test files) the same bug rendered Test Files 3 failed | 42 passed as PASS (430) FAIL (0) — three files that never ran, invisible.
Note the contrast with #672 (pytest xfailed shown as failed), which was falsely alarming while its exit code was correct. This one is falsely reassuring, which is the more dangerous direction.
Environment
- rtk 0.48.0 (Homebrew)
- macOS 26.4.1, arm64
- vitest 2.1.x, Node via npx
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the rtk vitest command and trace how the Vitest JSON reporter data becomes the summary. Reproduce the provided fixture with one broken test file, then verify the output no longer looks green when suite failures are present and success is false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rust
- Domain
- cli, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100