feat: Add Page.expect_screenshot/2#56
Merged
Merged
Conversation
ftes
approved these changes
Jun 16, 2026
ftes
left a comment
Owner
There was a problem hiding this comment.
Beautiful. Some tiny suggestions and one question.
98f8ecc to
76d0343
Compare
ftes
added a commit
to ftes/phoenix_test_playwright
that referenced
this pull request
Jun 18, 2026
When writing browser tests, we sometimes need to assert visual changes in elements — layout shifts, style regressions, rendering differences. `@playwright/test` ships `toHaveScreenshot` for exactly this, but it's not accessible from Elixir. This PR introduces `assert_screenshot/3`, a helper built on the same underlying Playwright `expectScreenshot` protocol command that powers `toHaveScreenshot`. 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.exs` points at that branch and will need updating once it merges. --------- Co-authored-by: Fredrik Teschke <f@ftes.de>
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.
@playwright/testshipstoHaveScreenshotfor visual regression testing, but the underlyingexpectScreenshotprotocol command was not exposed in this library. This PR addsPage.expect_screenshot/2, including alocatoropt to scope the screenshot to a specific element, to support building atoHaveScreenshot-equivalent helper in Elixir.