Rayrun
← Back to Discord Forum

Visual comparison - smaller screenshot sizes

Is there any way to reduce the size of the screenshots when using toHaveScreenshot? When running a lot of tests with screenshot comparison, the PNG size can pile up quite a bit.

This thread is trying to answer question "Is there any way to reduce the size of the screenshots when using toHaveScreenshot?"

13 replies

capture only the locator you want to verify. If you don't want that you can use clip i guess

I would like to validate full page.. but not save PNG, and use format that is lower in size as jpg

dirvinautomation_16636

Yes, just tell playwright to save a jpg by naming it as such.

Screenshot_2023-10-31_at_5.05.33_PM.png

@vgagaleski toHaveScreenshot only support png if you want other type you should use (page.screenshot()).toHaveSnapshot() and input the snapshotOption or screenshotOption {type: jpg} I dont really remember

hmmm, let me try that, but I cannot seem to find any toHaveSnapshot method

@vgagaleski my bed it's toMatchSnapshot()

This is great information, thanks a lot, I will give it a try

If you test using multiple browsers, make sure to have baseline JPGs per browser.

I don't know if the JPG encoding comes from the browsers or Playwright, but each browser will return a different JPG.

You can use https://argos-ci.com/ to upload screenshots and avoid commit it in your repository. So you don't care about the size of screenshots and it is easier to maintain.

I will check this out as well, thanks everyone

we were planning to use S3 as storage

@vgagaleski: Here is our Playwright presentation page: https://argos-ci.com/playwright

Here is our Playwright presentation page: https://argos-ci.com/playwright

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].