Skip to content

fix(playwright): consume the value of a space-separated --reporter flag - #3572

Open
guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:fix/playwright-reporter-value-leak
Open

guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:fix/playwright-reporter-value-leak

Conversation

@guyoron1

@guyoron1 guyoron1 commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • rtk playwright test forces --reporter=json and strips the user's own reporter flag, but for the space-separated form (--reporter list) it removed only the --reporter token and kept list
  • Playwright treats the leftover bare word as a positional test filter, so the run silently executes the wrong (usually empty) test set: 0 tests run, exit 1, "No tests found matching ..."
  • Fix: strip both --reporter=<name> and --reporter <name> (the flag and its value) before injecting the forced JSON reporter

Reproduction

# project with one passing spec
$ npx playwright test --reporter=json         # stats.expected = 1, exit 0
$ npx playwright test --reporter=json list    # what rtk used to run for 'rtk playwright test --reporter list'
                                              # stats.expected = 0, exit 1 (no tests match 'list')

Checked against a real Playwright 1.63 project: on develop rtk playwright test --reporter list runs --reporter=json list, so 0 tests and exit 1; with this branch it runs both tests and exits 0, as do --reporter=list and no flag.

Notes

#3060 fixes the same leak differently, by leaving an explicit reporter untouched (both forms) and returning the native output, which is the approach vitest and deno already take. This PR keeps the forced-JSON summary and only stops the leak. Happy to close it in favour of #3060 if that is the direction the maintainers prefer. I built #3060 on develop and ran it against the same project: --reporter list prints the native list output, --reporter=dot the dot output, no flag still gives the compact summary, and exit codes are preserved.

Test plan

  • tests/playwright_reporter_test.rs (stand-in npx recording argv): --reporter list must not leave list behind as a test filter (on develop the argv is [..., "--reporter=json", "list", ...]), and the equals form is still replaced
  • the four unit tests test_strip_reporter_* (space form consumes the value, equals form, unrelated args kept, trailing flag without a value)
  • cargo fmt --all -- --check, cargo clippy --all-targets (0 warnings), cargo test --all (all pass)

'rtk playwright test --reporter list' stripped only the --reporter token,
leaving 'list' behind as a positional argument. Playwright treats it as a
test filter, so the run silently executes the wrong (usually empty) test
set: 0 tests run, exit 1, 'No tests found'.

Strip both --reporter=<name> and '--reporter <name>' (flag + value) before
injecting the forced --reporter=json.
@guyoron1
guyoron1 force-pushed the fix/playwright-reporter-value-leak branch from 7a1a717 to bd6246f Compare September 21, 2026 12:20
@guyoron1

Copy link
Copy Markdown
Contributor Author

Rebased on current develop, no conflicts. I added a test that pins the argv Playwright receives for --reporter list (the value no longer survives as a test filter); the unit tests from the original PR call a helper that doesn't exist on develop, so on their own they couldn't show the bug.

Heads-up on overlap: #3060 fixes the same leak differently, by leaving an explicit reporter untouched, like vitest and deno already do. I built #3060 on develop and ran it against a real Playwright 1.63 project: --reporter list prints the native list output, --reporter=dot the dot output, no flag still gives the compact summary, and exit codes are preserved. This PR keeps the forced-JSON summary and only stops the leak. Happy to close it in favour of #3060 if that's the direction you prefer.

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