meinaart / cypress-plugin-snapshots

Plugin for snapshot tests in Cypress.io
MIT License
491 stars 116 forks source link

Need for passing pixelmatch threshold because of differences in how chrome renders transformed elements #131

Open alirezamirian opened 4 years ago

alirezamirian commented 4 years ago

Describe the bug Long story short, there are subtle differences in how chrome renders colors in transformed elements (especially in case of rotation) in headed vs headless mode, which seems to be inevitable. So it seems in these cases, the threshold value of 0.01 which is passed to pixelmatch for is not good enough. Although it's not technically a bug in this plugin, an immediate alleviation would be to allow customizing this in pixelmatch options. More generally, being able to pass other options like diffColor or diffColorAlt to pixelmatch would be nice.

Here is where pixelmatch options is hard-coded now: https://github.com/meinaart/cypress-plugin-snapshots/blob/89f0dca1a2feec0a0a4b02d7bf4e8b119f4e6a16/src/utils/tasks/imageSnapshots.js#L108

To Reproduce TODO

Expected behavior It should be possible to pass pixelmatch options

Screenshots I can provide some screenshots about the color differences of a rotated element in headeless vs headed mode, if that helps.

Desktop (please complete the following information):