webdrivercss icon indicating copy to clipboard operation
webdrivercss copied to clipboard

Add generic helper function to assert results

Open amitaibu opened this issue 9 years ago • 4 comments

Something along this:

var assertResult = function(err, res) {
  assert.ifError(err);

  Object.keys(res).forEach(function(key) {
    res[key].forEach(function(value) {
      if (!value.isWithinMisMatchTolerance) {
        console.log(res);
        throw new Error('Error in baseline image');
      }
    })
  });
};

amitaibu avatar Aug 06 '15 11:08 amitaibu

I'm looking for something like this as well. I'd like tests to fail if it's not within tolerance, but I also don't want to write the same assertions again and again.

klamping avatar Sep 02 '15 18:09 klamping

I don't think this should be part of webdrivercss. Webdrivercss's job is to be a plugin to webdriverio to capture screenshots. Having assertion helpers seems like another package that would provide this value.

elicwhite avatar Sep 02 '15 19:09 elicwhite

This is for a specific function of webdrivercss that handles whether the diff is out of bounds as far as mismatch goes. There's an example here: https://github.com/webdriverio/webdrivercss#let-your-test-fail-when-screenshots-differ

I really think the default setting should be this assertion already in place, with the ability to customize it if you'd like.

klamping avatar Sep 03 '15 16:09 klamping

I happen to be of the belief that webdrivercss should have nothing to do with testing itself and thus shouldn't even have a tolerance setting. I think webdrivercss should purely take screenshots and then there should be other packages on top of webdrivercss that adds the other testing functionality / uploading to aplitools, api, etc. But that is probably a bigger conversation.

In fact, I'm going to start an issue for that.

See #113

elicwhite avatar Sep 03 '15 19:09 elicwhite