Skip to content

fix(jest): consume the values a stripped --reporters flag would bind - #3777

Open
kylehgc wants to merge 1 commit into
rtk-ai:developfrom
kylehgc:fix/jest-reporters-space-form
Open

kylehgc wants to merge 1 commit into
rtk-ai:developfrom
kylehgc:fix/jest-reporters-space-form

Conversation

@kylehgc

@kylehgc kylehgc commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Sibling of #3572 (playwright), same bug class on the jest path.

Bug: rtk jest --reporters default strips only the --reporters token in the arg-forwarding loop (src/cmds/js/vitest_cmd.rs), leaving default behind as a positional test-name filter — jest silently runs the wrong (usually empty) test set.

Fix: replace the prefix-only strip with a helper that consumes exactly the tokens jest's own yargs parsing would bind, verified against jest 30 (jest-cli declares reporters as type: 'array' with default greedy-arrays):

  • --reporters and --reporters=<v> are both greedy: every following non-flag token is a reporter value and is dropped with the flag (real jest: --reporters=default other fails with "Could not resolve a module for a custom reporter. Module name: other").
  • Singular --reporter (not a jest flag) binds at most one value under yargs unknown-option rules; only that token is consumed. --reporter=<v> binds none.
  • --watch/--watchAll are boolean and now matched exactly — the old starts_with("--reporter")/starts_with("--watch") prefix match swallowed --watchman and stripped --watchPathIgnorePatterns while leaking its value as a filter (the same positional-leak bug). Both forward intact now.
  • -- and everything after it are forwarded verbatim (jest treats all following tokens as positionals).

Tests: 12 unit tests covering the space form, greedy equals form, array-value consumption, flag boundary, singular-reporter one-value binding, boolean watch flags, value-carrying watch flags forwarded, run/--json, trailing flag without value, and the -- terminator (both position and post--- verbatim forwarding).

Gate: cargo fmt --all clean, cargo clippy --all-targets clean, cargo test --all green (2842 passed).

🤖 Generated with Claude Code

'rtk jest --reporters default' stripped only the --reporters token,
leaving 'default' behind as a positional test-name filter, so jest
silently ran the wrong (usually empty) test set. Same bug class as the
playwright fix in rtk-ai#3572, but jest's --reporters is a greedy yargs array
flag in BOTH the space and equals forms: every following non-flag token
is a reporter value and must be dropped with the flag. The singular
--reporter (not a jest flag) binds at most one value under yargs
unknown-option rules and is consumed accordingly.

Replace the prefix-only matching with exact flag names: --watch and
--watchAll are boolean and no longer swallow --watchman, and
--watchPathIgnorePatterns <value> is forwarded intact instead of having
its flag stripped and its value leaked as a filter.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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