feat: Add assert_screenshot/3 for visual regression testing#181
Merged
Conversation
Wigny
commented
Jun 15, 2026
ftes
requested changes
Jun 16, 2026
ftes
left a comment
Owner
There was a problem hiding this comment.
Thank you so much for this Wígny!
An excellent addition to phoenix_test_playwright, and two well crafted PRs.
Some small comments.
ftes
reviewed
Jun 16, 2026
15d517d to
c9921c3
Compare
ftes
reviewed
Jun 16, 2026
ftes
reviewed
Jun 16, 2026
Handle renamed error key `custom_error_message` (was `error_message`) in the `expect_screenshot` wire format introduced in playwright_ex 0.7.0.
7e1bb96 to
8775220
Compare
ftes
approved these changes
Jun 17, 2026
ftes
left a comment
Owner
There was a problem hiding this comment.
Thanks for the changes.
Especially the improvements to documentation is appreciated.
That made me think we should be more consistent regarding defaults:
Either duplicate all, or remove all defaults (and rely on playwright defaults).
Also, if you don't mind: Copy option doc text from playwright docs?
Happy to merge as is though.
ftes
reviewed
Jun 17, 2026
ftes
reviewed
Jun 17, 2026
ftes
approved these changes
Jun 17, 2026
Owner
|
Beautiful. Let's get this baby shipped. |
auto-merge was automatically disabled
June 17, 2026 13:40
Head branch was pushed to by a user without write access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When writing browser tests, we sometimes need to assert visual changes in elements — layout shifts, style regressions, rendering differences.
@playwright/testshipstoHaveScreenshotfor exactly this, but it's not accessible from Elixir.This PR introduces
assert_screenshot/3, a helper built on the same underlying PlaywrightexpectScreenshotprotocol command that powerstoHaveScreenshot.On the first run, it captures a screenshot and saves it as the baseline. On subsequent runs, it compares the live page against that baseline server-side, passing silently on match, failing with a diff image on mismatch.
Note: depends on ftes/playwright_ex#56. The
mix.exspoints at that branch and will need updating once it merges.