Skip to content

Comments

fix(playwright): fix JSON parser to match real Playwright output format#193

Open
USerik wants to merge 1 commit intortk-ai:masterfrom
USerik:fix/playwright-json-parser
Open

fix(playwright): fix JSON parser to match real Playwright output format#193
USerik wants to merge 1 commit intortk-ai:masterfrom
USerik:fix/playwright-json-parser

Conversation

@USerik
Copy link

@USerik USerik commented Feb 18, 2026

Three bugs caused rtk playwright test to always fail with EXIT: 1:

  1. Wrong argument order: --reporter=json was inserted before the subcommand (e.g. playwright --reporter=json test), but Playwright requires flags after the subcommand (playwright test --reporter=json).

  2. Float duration deserialization: PlaywrightStats.duration was typed as u64, but real Playwright output emits a float (e.g. 3519.703...), causing serde_json to fail with a type error.

  3. Wrong suite structure: Suites contain specs (not tests). Each spec has ok: bool and tests (per-browser executions). The old struct used tests: Vec<PlaywrightTest> directly in suites, which never matched real output and always failed JSON parsing.

Fixes:

  • Move --reporter=json to after the first arg (the subcommand)
  • Change duration: u64 to duration: f64 in PlaywrightStats
  • Rewrite PlaywrightSuitespecs: Vec<PlaywrightSpec>
  • Add PlaywrightSpec with ok: bool and tests: Vec<PlaywrightExecution>
  • Add PlaywrightExecution with status and results: Vec<PlaywrightAttempt>
  • Update PlaywrightAttempt to use errors: Vec<PlaywrightError> (array)
  • Add tests covering float duration, real suite structure, and failure details

Three bugs caused `rtk playwright test` to always fail with EXIT: 1:

1. **Wrong argument order**: `--reporter=json` was inserted before the
   subcommand (e.g. `playwright --reporter=json test`), but Playwright
   requires flags after the subcommand (`playwright test --reporter=json`).

2. **Float duration deserialization**: `PlaywrightStats.duration` was typed
   as `u64`, but real Playwright output emits a float (e.g. `3519.703...`),
   causing serde_json to fail with a type error.

3. **Wrong suite structure**: Suites contain `specs` (not `tests`). Each
   spec has `ok: bool` and `tests` (per-browser executions). The old struct
   used `tests: Vec<PlaywrightTest>` directly in suites, which never matched
   real output and always failed JSON parsing.

Fixes:
- Move `--reporter=json` to after the first arg (the subcommand)
- Change `duration: u64` to `duration: f64` in `PlaywrightStats`
- Rewrite `PlaywrightSuite` → `specs: Vec<PlaywrightSpec>`
- Add `PlaywrightSpec` with `ok: bool` and `tests: Vec<PlaywrightExecution>`
- Add `PlaywrightExecution` with `status` and `results: Vec<PlaywrightAttempt>`
- Update `PlaywrightAttempt` to use `errors: Vec<PlaywrightError>` (array)
- Add tests covering float duration, real suite structure, and failure details

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pszymkowiak
Copy link
Collaborator

Thanks for this! Could you rebase on master? The branch is 2 commits behind. We'll review once it's up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants