rtk vitest handler silently passes through Jest output — no compression when pnpm test runs Jest
#1,345 opened on Apr 16, 2026
Repository metrics
- Stars
- (48,085 stars)
- PR merge metrics
- (Avg merge 11d 1h) (45 merged PRs in 30d)
Description
Summary
The registry rule in src/discover/rules.rs matches vitest|jest|test and routes to rtk vitest, but the handler at src/cmds/js/vitest_cmd.rs parses only Vitest's JSON schema (numTotalTests, testResults[...]). Jest's JSON is shaped differently (numTestSuites, numPassTests). Tier-1 parse fails silently, Tier-2 regex partially catches text, Tier-3 falls through to raw output. Net effect on Jest repos: ~0 compression, no error surfaced.
Separately: the same rule's rewrite_prefixes does not include "pnpm test", so rtk rewrite "pnpm test" returns exit 1 even though the pattern matches — the command is classified as supported but fails to produce a rewritten form.
Reproduction
Environment: rtk v0.36.0 (Homebrew, macOS), zsh.
- Repo where
pnpm testruns Jest (e.g., an Expo / React Native workspace) rtk rewrite \"jest\"→ exit 3, rewrites tortk vitest <args>rtk viteston Jest's JSON output — parser fails, output passes through uncompressedrtk rewrite \"pnpm test\"→ exit 1 (no rewrite), despite the regex matching
Impact
In a Next.js + Expo monorepo (web = Vitest, mobile = Jest), rtk discover reports pnpm test at 618 invocations / ~170K tokens saveable over 30 days. With the current handler, Jest-side invocations contribute near zero savings because the parser silently fails.
Proposed options (not prescribing)
(a) Separate rtk jest handler that parses Jest JSON; route jest → rtk jest, keep vitest → rtk vitest.
(b) Generic rtk pnpm-test wrapper that detects runner at runtime and dispatches — covers mixed monorepos where pnpm test runs different runners per workspace.
(c) Extend rtk vitest with a second JSON tier for Jest before regex fallback. Smallest change, conflates two tools.
Plus a tiny fix regardless of shape: add \"pnpm test\" to rewrite_prefixes so the existing rule actually emits a rewrite.
Happy to open a PR once you pick the shape.
Related
Config-level workaround tracked separately in #1344 (would let users auto-allow jest/vitest without redesigning the handler).