From 13e6e830bddde63b6fce372bba25a30a1f9c177e Mon Sep 17 00:00:00 2001 From: "J. Peter M. Schuler" Date: Mon, 13 Sep 2021 13:47:07 +0200 Subject: [PATCH 1/2] [FEATURE] allow resemble.compare even if dimensions are not the same \n\nsee #94 --- README.md | 4 ++-- index.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) 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..6ee8e17 100644 --- a/index.js +++ b/index.js @@ -63,6 +63,9 @@ class ResembleHelper extends Helper { if (!options.outputSettings) { options.outputSettings = {}; } + if (!options.needsSameDimension) { + 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.`)); From 519149288e35b561ce897f9a545c2b5812ccbaca Mon Sep 17 00:00:00 2001 From: "J. Peter M. Schuler" Date: Sun, 3 Oct 2021 19:50:40 +0200 Subject: [PATCH 2/2] fix default value overriding custom value "false" --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6ee8e17..1f9d0cf 100644 --- a/index.js +++ b/index.js @@ -60,10 +60,10 @@ class ResembleHelper extends Helper { return new Promise((resolve, reject) => { - if (!options.outputSettings) { + if (options.outputSettings) { options.outputSettings = {}; } - if (!options.needsSameDimension) { + if (typeof options.needsSameDimension === 'undefined') { options.needsSameDimension = true; } resemble.outputSettings({