fix: honor screenshot pixel tolerances - #251
Conversation
|
I think you're underselling this. Your own reasoning kills the other branch too, and the PR leaves it standing. You say Playwright signals a real mismatch by erroring on the call. That matches what I found. But if that's true, then So the switch happened between 1.60.0 and 1.61.0, and this repo pins That also explains None of which argues against merging this. It's the same bug on the other branch of the same |
|
Checked the version boundary against the vendored source and it holds. The protocol schema is even more direct than the throw/return change: in 1.60.0 One correction to my own earlier reading. I had assumed the diff was simply lost once Playwright started throwing. It is not. Here is the raw websocket frame on a genuine mismatch, produced by painting a rectangle over the stored snapshot: So deleting the branch would throw away something that is still reachable. Wiring it up is the better direction. That part is not local to this I would keep this PR as the deletion and send the |
|
Checked the schema boundary against the vendored sources and it lines up. You're also right that I overstated the loss. I said all you get is the bare That splits your follow-up into two pieces of very different size, though. The image does need somewhere to live, and that's the design decision you're describing. The message doesn't. Worth knowing where that line sits, whichever way you go: #247 inserts its id check directly above that same One thing I checked that didn't pan out, in case you wonder the same: |
|
Agreed on the split, and the message half is in, as Verified end to end rather than from the schema: repainted a rectangle over the stored snapshot and ran the test. It now fails with Nothing else in the plugin reads that text, and On the collision: #247 merges over this cleanly. #241 does conflict, but on the The image still needs somewhere to live. Separate PR. |
expectScreenshot()compares the raw PNG bytes withtoMatchSnapshot()first, and only asks Playwright for a pixel comparison once those differ. But both paths out of thecatchthrow, so a screenshot Playwright reports as a match still fails the test, andmaxDiffPixels,thresholdanddetectAntialiasingnever get to decide anything. Chromium's PNG output is not byte-reproducible, so a handful of antialiased pixels is enough to fail a run at random.Playwright signals a real mismatch by erroring on the
expectScreenshotcall, which the websocket client already turns into a failed expectation before the loop below it runs. Dropping the trailing throw therefore keeps genuine regressions failing and lets the tolerances apply.To reproduce, take a screenshot assertion with a committed baseline and re-encode the stored snapshot so the pixels stay identical but the bytes change (appending a PNG
tEXtchunk does it). The test fails today and passes with this change.A separate commit covers what a genuine mismatch then reports. Since 1.61 Playwright puts only
Expect failedin the error and sends the pixel comparison result beside it aserrorDetails.customErrorMessage, so the client prefers that when the frame carries it. A failing screenshot assertion reads3659 pixels (ratio 0.01 of all image pixels) are different.instead ofExpect failed.Fixes pestphp/pest#1881