blueimp / wdio

Docker setup for WebdriverIO with automatic screenshots, image diffing and screen recording support for containerized versions of Chrome and Firefox on Linux, mobile versions of Chrome and Firefox on Android as well as Safari on iOS, Safari on macOS and Edge on Windows.
https://hub.docker.com/r/blueimp/wdio
MIT License
296 stars 51 forks source link

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

Closed harpet06 closed 5 years ago

harpet06 commented 5 years ago

browser.saveAndDiffScreenshot('test');

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

blueimp commented 5 years ago

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

harpet06 commented 5 years ago

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 commented 5 years ago

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