Rayrun
← Back to Discord Forum

maxDiffPixels vs maxDiffPixelRatio in toHaveScreenshot, who has priority?

Hi everyone! A quick question. When both maxDiffPixels and maxDiffPixelRatio are used in toHaveScreenshot, one from playwright test config, the other directly used as parameter of toHaveScreenshot's option, which one takes effect, the one in code, or the one in config, or both?

This thread is trying to answer question "When both maxDiffPixels and maxDiffPixelRatio are used in toHaveScreenshot, one from playwright test config, the other directly used as parameter of toHaveScreenshot's option, which one takes effect, the one in code, or the one in config, or both?"

1 reply

Both are actually used:

https://github.com/microsoft/playwright/blob/62b6af3a7f67b08e6588699a49753b7ed3f1e3df/packages/playwright-core/src/utils/comparators.ts#L86C30-L86C30

It takes the minimal value.

About the merging of config I am not sure, but if it merges global config and local options then both are used.

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 luc@ray.run.