blueimp/wdio

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

harpet06 opened this issue · 3 comments

browser.saveAndDiffScreenshot('test');

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

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

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

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