(feat) pixelmatch threshold control
enhancement
**Is your feature request related to a problem? Please describe.**
I want to be able to control pixelmatch threshold so I can control how different a pixel must be before pixelmatch considers it different.
**Describe the solution you'd like**
I'd like to be able to control pixelmatch threshold directly, instead of cypress-plugin-snapshots passing a hard coded 0.01.
**Describe alternatives you've considered**
Forking this repo. Using a different package. Adjusting threshold in cypress-plugin-snapshots config. Living with flaky tests and accepting new snapshots every day, which is annoying and hinders adoption of visual testing in my team.
**Additional context**
A snapshot that has imperceptible changes failed a test. I used pixelmatch directly to dial in a threshold that would tolerate the difference:
- `npx pixelmatch imageA.png imageB.actual.png 0.01` reports 354 different pixels
- `npx pixelmatch imageA.png imageB.actual.png 0.011` reports 0 different pixels (sweet spot, at least currently with this snapshot)
I like keeping the threshold for cypress-plugin-snapshots at 0 pixels, because I don't want to allow any room for visual regressions.
Here's the code where threshold is utilized to determine if tests pass or not. Just above this, you can see where the hard coded pixelmatch threshold is passed.
https://github.com/meinaart/cypress-plugin-snapshots/blob/6b95c7a930364b99f2496922159a6d693ad684a2/src/utils/tasks/imageSnapshots.js#L130C1-L138C6
1 条评论