chore: throw on Frame.expect / Page.expectScreenshot failure#40801
chore: throw on Frame.expect / Page.expectScreenshot failure#40801dgozman wants to merge 4 commits into
Conversation
Frame.expect now throws ExpectError on mismatch instead of returning a result. Carries strongly-typed details (received, timedOut) validated against a new FrameExpectErrorDetails schema in protocol.yml. The dispatcher routes details through a generic per-method ErrorDetails validator next to the response error on the wire, and the client surfaces them on the rejected PlaywrightError, letting Frame._expect rebuild ExpectResult. _wrapApiCall skips its apiName-prefix and call-log decoration when the error carries details so matchers format their own output.
Nothing ever sets it, so the option only existed to gate code paths that can't be triggered. Removing it lets the one-shot/retry blocks stop threading ExpectError through internal catches: the single throw site is now the outer catch that wraps the failure into a typed ExpectError.
…rmat
Page.expectScreenshot now throws on mismatch with bolted-on details,
mirroring Frame.expect. The protocol's `expectScreenshot.returns` is
narrowed to `{ actual? }` and an `errorDetails:` block carries the diff
payload.
The dispatcher always emits `errorDetails` (validated against the
per-method schema, defaulting to `{}`) for any method that defines one,
so the wire's presence of `errorDetails` becomes the matcher-error
discriminator. The throw site no longer needs to bolt empty details.
Frame.expect's outer catch strips the `Error: ` prefix from messages
raised inside `evaluate` (V8 / createStacklessError already prepended
it); the client unconditionally re-adds it, so YAML parse errors and
strict-mode violations end up with the same `Error: …` shape inside the
matcher's failure message.
Test results for "MCP"23 failed 7047 passed, 1068 skipped Merge workflow run. |
Test results for "tests 1"18 failed 3 flaky41746 passed, 850 skipped Merge workflow run. |
Restores `received` in the FrameExpect success response so matchers and trace viewer can use it. `toMatchAriaSnapshot` needs it to write rebaselines in `--update-snapshots=all` mode; the trace viewer's "Return value" section uses it to display the matched text.
Summary
Frame.expectandPage.expectScreenshotthrow on failure instead of returning the diff payload. Failure details ride on a new per-methoderrorDetails:block in protocol.yml; the dispatcher always sendserrorDetails(validated against the schema, defaulting to{}) for any method that defines one, so its presence on the wire is the matcher-error discriminator.noAutoWaitingoption onFrame.expectis gone, which lets the one-shot/retry blocks stop threading the wrapper error through internal catches.Error:when surfacing them aserrorMessage. YAML parse errors and JS-error/strict-mode messages now end up with the same shape inside the matcher's failure header.