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

Is there an easy way to make the test fail if a new screenshot is generated? #4

Closed
harpet06 opened this issue Mar 29, 2019 · 3 comments

Comments

@harpet06
Copy link

browser.saveAndDiffScreenshot('test');

say the above command creates a diff, is there a way to make that fail the test easily?

@blueimp
Copy link
Owner

blueimp commented Mar 29, 2019

I've just added a new commit that is included in the new version 2.3.0 of wdio-screen-commands and updated the dependency in this project, so now you can do the following:

const ssim = browser.saveAndDiffScreenshot('screenshot name')
if (ssim && ssim.All < 1) {
  // Screenshot differs from previous run
  // See also: https://github.com/blueimp/node-ffmpeg-image-diff
}

In my experience, failing tests for screenshot differences might give you too many false negatives though, as e.g. it's easy to have differences that are due to

  • browser rendering changes
  • os font rendering changes
  • changes due to animation states
  • changes outside of the browser viewport, e.g. different clock times in screenshots of mobile devices

@harpet06
Copy link
Author

Thanks for the quick response, I'll try that out.

I've wrote a quick command to strip out more volatile bits of the pages, so hopefully we won't get too many false negatives

@blueimp
Copy link
Owner

blueimp commented Mar 29, 2019

Thanks, please let me know if we can close the issue (or feel free to close it yourself).

yamafaktory pushed a commit to allthings-archive/wdio that referenced this issue Jul 11, 2019
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

2 participants