Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hasSizeMismatch auto-failure should be made optional #83

Closed
phawxby opened this issue Jun 7, 2018 · 4 comments
Closed

hasSizeMismatch auto-failure should be made optional #83

phawxby opened this issue Jun 7, 2018 · 4 comments

Comments

@phawxby
Copy link
Contributor

phawxby commented Jun 7, 2018

We develop on windows but visual regression runs on Linux. The the most-part this is fine, however every now and then we find a component might render 1px bigger or smaller in terms of crop, it's otherwise identical.

https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js#L130

image

@anescobar1991
Copy link
Member

So you're proposing a flag to disable that behavior? I wouldn't be opposed to that.

In terms of your issue at hand have you tried running the tests inside a docker container? That is what we do to prevent differences between operating systems. I believe CodeSandbox does that same thing.

@sbekrin
Copy link
Contributor

sbekrin commented Jun 16, 2018

Hey @phawxby, I had similar issue and can suggest few things:

  1. Use selenium/puppeteer server for consistent output. Running VR tests in different environments is unreliable and would likely to fail due to different text-rendering and image anti-aliasing;
  2. Auto-crop whitespace area before comparing images. It's possible to do with Jimp.

Hope that helps 🙌

@phawxby
Copy link
Contributor Author

phawxby commented Jun 16, 2018

Thanks for the help guys. I ended up getting this solved last week using Docker, and helpfully CircleCI publish their docker images publicly so I'm actually generating the image snapshots using the exact same docker image that's I'm using during CI, very helpful.

As for auto-cropping, I'm using puppeteer element screenshot of which natively crops the screenshot to just that of the target element.

I think I've got this one all covered. Thanks

@booxood
Copy link

booxood commented Aug 3, 2018

Hope can add hasSizeMismatch can be optional, because sometimes want to ignore 1px or 2px differences.

@anescobar1991 Will accept PR? Add one option, no 'harm', right?

anescobar1991 pushed a commit that referenced this issue Apr 17, 2020
if the option `allowSizeMismatch` is set, a build will not always fail on
images with different sizes. Missing or Added Pixel will be counted as a
mismatch and respected by the set threshold.

Related #83, #85
oneamexbot added a commit that referenced this issue Apr 17, 2020
# [3.1.0](v3.0.1...v3.1.0) (2020-04-17)

### Features

* **options:** add option to pass on size missmatch ([#174](#174)) ([cee46b1](cee46b1)), closes [#83](#83) [#85](#85)
goverdhan07 pushed a commit to goverdhan07/jest-image-snapshot that referenced this issue Jul 23, 2023
)

if the option `allowSizeMismatch` is set, a build will not always fail on
images with different sizes. Missing or Added Pixel will be counted as a
mismatch and respected by the set threshold.

Related americanexpress#83, americanexpress#85
goverdhan07 pushed a commit to goverdhan07/jest-image-snapshot that referenced this issue Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants