diff --git a/README.md b/README.md index 15b20e1..4aba0a9 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ These are the major functions that help in visual testing: First one is the `seeVisualDiff` which basically takes two parameters 1) `baseImage` Name of the base image, this will be the image used for comparison with the screenshot image. It is mandatory to have the same image file names for base and screenshot image. -2) `options` options can be passed which include `prepaseBaseImage` and `tolerance`. +2) `options` options can be passed which include `prepaseBaseImage`, `tolerance` and `needsSameDimension`. ```js /** * Check Visual Difference for Base and Screenshot Image * @param baseImage Name of the Base Image (Base Image path is taken from Configuration) - * @param options Options ex {prepareBaseImage: true, tolerance: 5} along with Resemble JS Options, read more here: https://github.com/rsmbl/Resemble.js + * @param options Options ex {prepareBaseImage: true, tolerance: 5, needsSameDimension: false} along with Resemble JS Options, read more here: https://github.com/rsmbl/Resemble.js * @returns {Promise} */ async seeVisualDiff(baseImage, options) {} diff --git a/index.js b/index.js index 89da5dd..1f9d0cf 100644 --- a/index.js +++ b/index.js @@ -60,9 +60,12 @@ class ResembleHelper extends Helper { return new Promise((resolve, reject) => { - if (!options.outputSettings) { + if (options.outputSettings) { options.outputSettings = {}; } + if (typeof options.needsSameDimension === 'undefined') { + options.needsSameDimension = true; + } resemble.outputSettings({ boundingBox: options.boundingBox, ignoredBox: options.ignoredBox, @@ -76,7 +79,7 @@ class ResembleHelper extends Helper { if (err) { reject(err); } else { - if (!data.isSameDimensions) { + if (options.needsSameDimension && !data.isSameDimensions) { let dimensions1 = sizeOf(baseImage); let dimensions2 = sizeOf(actualImage); reject(new Error(`The base image is of ${dimensions1.height} X ${dimensions1.width} and actual image is of ${dimensions2.height} X ${dimensions2.width}. Please use images of same dimensions so as to avoid any unexpected results.`));