Prior99 / jest-screenshot

A jest extension to deal with screenshots and all sorts of images.
MIT License
71 stars 21 forks source link

pixelThresholdRelative option not working #3

Closed Jack89ita closed 6 years ago

Jack89ita commented 6 years ago

Hello again! I've got a problem with the pixelThresholdRelative param. This is my config:

setupJestScreenshot({
  detectAntialiasing: false,
  pixelThresholdRelative: 0.5
});

So i expect that the test will fail if 50% or more pixels are different but instead i got this message from console:

Expected less than 0.00% of the pixels to have changed, but 4.37% of the pixels changed.

Any tip? Thank you!

Prior99 commented 6 years ago

The configuration shouldn't be provided to setupJestScreenshot() but instead you need to create a jest-screenshot.json file in your project's root directory with that configuration or put it into your package.json behind a jestScreenshot key.

I see that this can be confusing, but as well the reporter as the custom matcher need to access the configuration and they run in different processes.

Jack89ita commented 6 years ago

Perfect!now it's working as expected! Thank you!