rtk jest reports `PASS (N) FAIL (0)` when a test suite fails to compile — suite-level failures excluded from the summary
Summary
The dedicated jest filter counts only executed test results and ignores suite-level failures (compile/collection errors). A suite that fails to load (SyntaxError, bad transform, unresolved import) disappears from the summary entirely: rtk prints PASS (N) FAIL (0) while raw jest prints Test Suites: 1 failed, ….
Same failure class as #2317 (pytest collection error → "No tests collected"), jest variant. Notably, the generic rtk test handler already gets this right — only the jest-specific filter is affected.
- rtk 0.40.0, Linux (WSL2), jest 30
Minimal repro
mkdir rtk-repro && cd rtk-repro
printf '{"name":"rtk-repro","private":true}' > package.json
npm i jest@30
printf 'test("ok", () => expect(1).toBe(1));\n' > ok.test.js
# ESM syntax in CJS context -> suite fails to compile, its test never runs
printf 'export {};\ntest("never runs", () => expect(1).toBe(2));\n' > broken.test.js
Raw jest (exit 1):
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
rtk jest (exit 1, but the text is a false green):
PASS (1) FAIL (0)
[full output: ~/.local/share/rtk/tee/..._jest_run.log]
rtk test npx jest — the generic handler shows the truth:
[FAIL] FAILURES:
FAIL ./broken.test.js
SUMMARY:
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
Why the propagated exit code isn't enough
In agent workflows (rtk's primary audience) the displayed text is what the model reasons over, and the exit code is routinely eaten by pipelines: npx jest 2>&1 | tail -5 returns tail's exit status. PASS (N) FAIL (0) reads as an unambiguous green.
Real-world impact: in an autonomous run on a real project, a brand-new test suite (7 tests) had a transitive import that broke its compilation. Three consecutive "green" verification passes — including a clean-room npm ci re-run — all showed PASS (N) FAIL (0), because N only counted the other suites' tests. The suite had literally never executed. It was only caught later by a mutation-testing audit that ran ./node_modules/.bin/jest directly and read the Test Suites: line.
Suggested fix
Parse jest's Test Suites: summary line and surface suite-level failures in the compact output, e.g.:
PASS (1) FAIL (0) SUITES-FAILED (1: broken.test.js)
or fall back to the generic test handler's behavior whenever Test Suites: X failed is present. Anything but a bare PASS (N) FAIL (0) when a suite failed to load.
🤖 Filed with Claude Code on behalf of the user.
wshm · Automated triage by AI
🔍 Automated Triage
| 🐛 Category | bug |
| 🟠 Priority | high |
| 🎯 Confidence | 94% |
Summary
rtk's jest-specific output filter ignores suite-level compile/collection failures, printing a false-green PASS/FAIL summary; fix by parsing the 'Test Suites:' line or falling back to the generic test handler.
📁 Relevant files
src/filters/jest.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Still present in rtk 0.51.0 (aarch64-apple-darwin) with jest 30.5.2 on Node 24.16.
Minimal repro, one test file whose import doesn't resolve:
mkdir rtk-jest-suite && cd rtk-jest-suite
echo '{ "name": "rtk-jest-suite", "private": true }' > package.json
npm i -D jest
echo "test('ok', () => expect(1).toBe(1))" > ok.test.js
printf '%s\n' "const x = require('./does-not-exist')" "test('never runs', () => expect(x).toBeDefined())" > broken.test.js
rtk jest; echo "exit $?"
PASS (1) FAIL (0)
[full output: ~/…/rtk/tee/…_jest_run.log]
exit 1
Raw jest prints Test Suites: 1 failed, 1 passed, 2 total. I can confirm that the generic handler gets it right. rtk test npx jest prints:
[FAIL] FAILURES:
FAIL ./broken.test.js
SUMMARY:
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
Still present in rtk 1.2.0 (Homebrew formula rtk-oss, aarch64-apple-darwin) with jest 30.x on Node v24.11.1, inside a NestJS backend using ts-jest. The last version in this thread is 0.51.0.
Repro — one spec file whose import does not resolve:
// test/unit/zz-repro.spec.ts
import { doesNotExist } from './nonexistent-module-xyz';
it('never runs', () => {
expect(doesNotExist).toBeDefined();
});
Raw jest (exit 1):
FAIL test/unit/zz-repro.spec.ts
● Test suite failed to run
test/unit/zz-repro.spec.ts:1:30 - error TS2307: Cannot find module './nonexistent-module-xyz' or its corresponding type declarations.
1 import { doesNotExist } from './nonexistent-module-xyz';
~~~~~~~~~~~~~~~~~~~~~~~~~~
Test Suites: 1 failed, 1 total
Tests: 0 total
rtk jest test/unit/zz-repro.spec.ts (exit 1):
PASS (0) FAIL (0)
[full output: rtk recall 95714c69a0dcdafe]
Two details worth adding to the report:
- The summary does not even carry the failing suite count — it is
PASS (0) FAIL (0), i.e. zero tests ran and one suite failed. An empty-looking count is what makes it read as a green no-op rather than a failure. - The exit code is correct (1) and the recall hint does point at the raw output, so the failure is recoverable — but only for a caller that reads the hint. The mitigation we use in CI is to treat
PASS (0) FAIL (0)as a failure signal rather than a pass, and to read the recall hint whenever the counts come back empty.
Closing as a duplicate of #3935: rtk jest and rtk vitest use the same JSON summary code, and that code ignores failed suites for both, so the fix tracked in #3935 covers jest as well. Please follow up there, and jest-specific details such as the ts-jest case where every suite fails are welcome on that issue.