Skip to content

fix(playwright): fix JSON parser and binary resolution#215

Merged
pszymkowiak merged 1 commit intortk-ai:masterfrom
edsai:fix/playwright-parser
Feb 20, 2026
Merged

fix(playwright): fix JSON parser and binary resolution#215
pszymkowiak merged 1 commit intortk-ai:masterfrom
edsai:fix/playwright-parser

Conversation

@edsai
Copy link
Contributor

@edsai edsai commented Feb 19, 2026

Fixes three bugs that cause rtk playwright test to fall through to passthrough mode (Tier 3) instead of parsing JSON output (Tier 1):

1. JSON struct mismatch

The parser expected suites[].tests[] but Playwright's JSON reporter outputs suites[].specs[].tests[].results[]. Added the missing PlaywrightSpec intermediate struct, use spec.ok for failure detection, and changed error from Option<String> to errors: Vec<PlaywrightError> to match the array format Playwright emits.

2. Float duration

Playwright emits stats.duration as a float (e.g. 3519.7039999999997). The struct had u64, causing deserialization to fail. Changed to f64.

3. pyenv shim collision

which playwright can resolve to a pyenv shim (Python's playwright package), which doesn't have a test subcommand. This causes the spawned process to error out before producing any JSON. Fixed by always resolving through the detected package manager (npx/pnpm exec/yarn exec) instead of which.

Also strips any user-supplied --reporter flags so they don't conflict with the forced --reporter=json.

Tested against real Playwright test suites — parser now reliably hits Tier 1 (full JSON parse).

Three bugs fixed:

1. JSON struct mismatch: The parser expected `suites[].tests[]` but
   Playwright's JSON reporter outputs `suites[].specs[].tests[]`.
   Added PlaywrightSpec layer, use `spec.ok` for failure detection,
   and `errors: Vec<PlaywrightError>` (array, not Option).

2. Float duration: Playwright emits `duration` as f64, not u64.
   Changed struct field type to avoid deserialization failures.

3. pyenv shim collision: `which playwright` can resolve to a pyenv
   shim (Python's playwright) which lacks a `test` subcommand.
   Bypass `which` entirely and resolve through the detected package
   manager (npx/pnpm/yarn).

Also strips user-supplied `--reporter` flags to avoid conflicts with
the forced `--reporter=json`.
@pszymkowiak
Copy link
Collaborator

LGTM — tested locally on the branch, all good.

  • 398 tests pass, no conflicts with master
  • 82/83 smoke tests pass (1 false positive: test script hardcodes expected test count)
  • 23 commands tested manually: git status/log/diff/branch, ls, read, find, grep, gh pr/issue list, deps, env, summary, err, test, gain, cargo build, tsc/lint/vitest/docker/playwright help
    — zero regressions
  • rtk playwright test without a Playwright project: falls back cleanly to passthrough (no crash)
  • All 3 fixes are solid: JSON struct matches real Playwright output (suites→specs→tests→results), float duration handled, pyenv shim collision avoided
  • Good test coverage added: float duration, failure with error messages, nested suites

@pszymkowiak pszymkowiak merged commit 461856c into rtk-ai:master Feb 20, 2026
heAdz0r added a commit to heAdz0r/rtk that referenced this pull request Feb 28, 2026
Upstream 0.22.2 sync (all previously missing fixes verified applied):
- fix(lint): propagate linter exit code (rtk-ai#207) — CI false-green fix
- feat: add rtk wc command for compact word/line/byte counts (rtk-ai#175)
- fix(playwright): JSON parser (specs layer) + binary resolution (rtk-ai#215)
- fix(grep): propagate rg exit codes 1/2 (rtk-ai#227)
- fix(git): branch creation not swallowed by list mode (rtk-ai#194)
- fix(git): support multiple -m flags in git commit (rtk-ai#202)
- fix(grep): BRE \| translation + strip -r flag (rtk-ai#206)
- fix(gh): smart markdown body filter for issue/pr view (rtk-ai#214)
- fix(gh): gh run view --log-failed flag passthrough (rtk-ai#159)
- feat(docker): docker compose support (rtk-ai#110)
- feat: hook audit mode (rtk-ai#151)
- feat: tee raw output to file (rtk-ai#134)

Version bump: 0.21.1-fork.19 → 0.22.2-fork.1

Co-Authored-By: Claude Sonnet 4.6 <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.

2 participants