-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: better support for visual regression testing #8161
Comments
I think https://github.com/americanexpress/jest-image-snapshot provides a nice suite of options for various VRT scenarios. Test scenarios vary widely, depending on the context (testing components, whole pages, text-heavy or not, etc). Besides bluring which helps a lot with antialiasing it would be nice if multiple image comparisons (e. g. SSM) would be possible. Alternative image comparison algorithms could be left to userland, if they can be plugged into |
@florianbepunkt What's SSM? Is it structural similarity measurement (SSIM)? |
@aslushnikov Yes, typo. |
@kevinmpowell What's the one that you find most handy? Is it a "slider" diff like here: |
I actually prefer the pixel highlighting (like Playwright already does), but organize all the failing tests in a UI so I can see what failed without having to poke around three different images. Also being able to A/B toggle the baseline and the test image is nice in some cases. |
Slider is rarely useful for me. An onion-skin (transparency overlay) would be more useful. |
@aslushnikov Why Thanks for thinking about Visual Regression testing. Thats important! |
On a related note: It would be great if tests could be run cross-plattform. Currently the os platform name is baked into the snapshot filename, so our CI tests sometime fail due to name miss-match. #7575 |
It would be nice if we could choose whether we want to apply such image filters before the snapshot is being saved or only when doing the comparison. I would prefer the first option as it keeps the diff small when creating new snapshots even of such images that change randomly / are flaky. |
Thanks for thinking on this, blur feature is something that will help us, we have something similar before with puppeter that help us to do comparisson in animated pages, in addition to that something that can be really useful is be able to ignore specific parts of the screen, specially in those parts where we have more dynamic data(videos/images) |
Blur would help us greatly. Also, the slider view would be incredible as well. |
We're also really interested in these improvements. We had to disable visual tests for now because they are randomly failing because a few pixels are off, even when increasing the threshold. Blur should help here hopefully. |
I suggest solving biggest pain-point which is how to store this stuff in git repo so it doesn't blow up in size (to store only last snapshot). Git LFS kinda works but it's painful. Maybe something else would work better? For reference: americanexpress/jest-image-snapshot#92 Would be great if these snapshot dirs were automatically marked in git to only store last revision. |
We're using Git LFS, what's your issue with it? Once we had it set up for everyone (we're using Mac, Windows and Linux), it worked fine. We're storing all images in the repo using Git LFS ( The only issue I have is comparing the image diffs in VS Code when committing new images as the old image is not shown in the diff view. The diff is working fine in the GitLab merge request view though so that's not a big issue. |
@gselsidi thank you for the sample! |
I'll try to get some more as they come along, but i noticed the above occurs when taking snapshots of individual elements as opposed to the whole page. The whole page I'm able to use .0001 pixel ratio. |
linking this here incase it applies: |
I had different screenshots with antialiased fonts between my ArchLinux laptop and Ubuntu 20.04 in Docker (it's used by default by GitHub Actions). The following Chromium flags helped me to get identical screenshots:
|
We have similar issues with webkit on mac around emojis, I am not sure if we can provide further information to make debugging/fixing the issue easier? It looks like mask is not available to configure at |
@nikicat Where exactly did you add these flags in your playwright project? |
@thekp I pass them to |
We test screenshots off add-in the web MS Office 365 Excel. In some cases, size of add-in is 1px bigger than original. It seems we cannot control it. MS Office decides for this and is not deterministc. Image diff is negligible, and we could ignore it, but since size of image do not match toMatchSnapshot fails. I would vote for toMatchSnapshot be able to compare images of different size. |
One of the things we noticed is that our focus is somewhat different between runs (imagine loading a page with a text input, sometimes the text input is focused, sometimes it isn't). Wondering if there's anything we can do to improve reliability apart from just manually blurring and focusing |
My discrepancy was resolved by passing the
|
I wonder if some of the font rendering discrepancies might be because of local fonts being used instead of web fonts. For example, I have the Rambla font installed locally on my Mac, but my site also pulls that font in via CSS. In that case, consistently running the tests in an environment that does not have those fonts installed locally might address the problem. This might mean replacing the "expected" image with one from an environment that doesn't have the font installed.
M. Scott Ford
Co-Founder & Chief Code Whisperer (CTO)
Corgibytes, LLC
804.596.2375 x701
pronouns: he/him
***@***.***
https://corgibytes.com ( https://corgibytes.com/ )
Have you read our First Round Review ( http://firstround.com/review/forget-technical-debt-heres-how-to-build-technical-wealth/ ) article about paying off technical debt?
Love refactoring and TDD? Join us at LegacyCode.Rocks ( http://LegacyCode.Rocks ) for virtual meetups, podcasts, and more.
Sent via Superhuman ( ***@***.*** )
…On Mon, May 22, 2023 at 5:01 AM, Guillermo De Fermín < ***@***.*** > wrote:
Hi, posting a flaky screenshot due to font rendering:
The baseline creation and the test run were both done on the mcr. microsoft.
com/ playwright:v1. 28. 0-focal (
http://mcr.microsoft.com/playwright:v1.28.0-focal ) docker image
Expected
(
https://user-images.githubusercontent.com/7784127/239858688-1c8b6ef5-e033-427e-abf0-a3ea02fa9746.png
) Actual
(
https://user-images.githubusercontent.com/7784127/239858703-e7848cc1-986c-4ad8-98cf-d01df2c4ff78.png
) Diff
(
https://user-images.githubusercontent.com/7784127/239858699-24bd8502-e069-4726-8a70-1dcc75be53a6.png
)
—
Reply to this email directly, view it on GitHub (
#8161 (comment)
) , or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AAAFGXBJYEO3C4MRZJAIFXLXHMTN7ANCNFSM5CAZUKGQ
).
You are receiving this because you are subscribed to this thread. Message
ID: <microsoft/playwright/issues/8161/1556830269 @ github. com>
|
nods yeah, that's what I figured. I'm currently working around it by setting
Good reminder. We're doing that with https://github.com/deviantintegral/ddev-playwright and the above screenshots are from running tests in a loop until they fail, all in the same environment. |
There's a separate (related) issue regarding adding support for docker at #20954 so that visual regression tests can run in a consistent environment and environment-related differences are negated. It would be helpful to receive upvotes there from folks here if that's something you need. |
I am encountering the same issue with chromium (and webkit at an even higher frequency, too high so we disabled it). Version: Playwright 1.38.1 (but the issue is reproducible as well in 1.39.0)
My guess: this issue never happens on other screenshots that we are taking using exactly the same configuration, so it has to do with something in the HTML / CSS (that I am probably not allowed to share here)... Actual / expected / diff (triggering here on the pseudo-locale test but might happen as well on the en-US version): |
Hi, this appeared with the latest version, nothing like this happened before with the same code and configuration. Playwright version: 1.41.1
Example 1: Example 2: |
An update from our experiences above: We found that increasing |
Hey folks! Any updates on this feature? 😅 I am facing the same behavior after switching to a recent Playwright version ( FWIW, it was working correctly on the Playwright version Thanks! UPDATE: Sorry, folks, I am an idiot 😀 import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'], channel: 'chromium' },
},
],
}); So it all works for me now! |
Playwright needs better support: microsoft/playwright#28005 microsoft/playwright#29227 microsoft/playwright#8161 microsoft/playwright#18937 This reverts commit 62242bf.
Playwright Test has a built-in
toMatchSnapshot()
method to power Visual Regression Testing (VRT).However, VRT is still challenging due to variances in the host environments. There's a bunch of measures we can do right away to drastically improve experience in @playwright/test
docker
test fixture to run browsers inside docker image.blur
in matching snapshot to counteract antialiasingInteresting context:
The text was updated successfully, but these errors were encountered: