web icon indicating copy to clipboard operation
web copied to clipboard

Ability to provide pixelmatch config per snapshot

Open trusktr opened this issue 3 years ago • 5 comments

I find that some snapshots fail by a small percentage while others never do. It would be nice to be able to specify a threshold only for specific visualDiff() calls.

trusktr avatar Dec 14 '22 01:12 trusktr

If you had a theoretical path towards making this possible, we'd certainly discuss it. However, I've found that some browsers just won't give up sometimes displaying pixels incorrectly and my project is better off making use of retries than trying to configure the work at that level of granularity.

Westbrook avatar Feb 16 '23 02:02 Westbrook

In my project, I have a failureThreshold: 1.25, config so that my tests pass on CI and and locally. The problem is that I could set the failureThreshold much lower on Chrome without any issue. I have to set it this high to work around Safari display differences that I can't fix.

Lookwe69 avatar Jul 21 '25 18:07 Lookwe69

If you're running into the difference at a browser level, have you tried running the tests separately for each browser with a different config file?

You should be able to share all of the base configuration and then only override the browser configs in that case.

Westbrook avatar Jul 21 '25 19:07 Westbrook

Having two configurations will cause problems when I want certain features, such as coverage. + It's cumbersome :(

Lookwe69 avatar Jul 21 '25 21:07 Lookwe69

It may be cool a feature such as failureThreshold supports (browser: string) => boolean.

Lookwe69 avatar Jul 21 '25 21:07 Lookwe69