webdrivercss
webdrivercss copied to clipboard
Add generic helper function to assert results
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');
}
})
});
};
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.
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.
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.
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