Skip to content

Commit b8d7e27

Browse files
authored
[FEATURE] allow resemble.compare even if dimensions are not the same (#96)
* [FEATURE] allow resemble.compare even if dimensions are not the same \n\nsee #94 * fix default value overriding custom value "false"
1 parent 774ecd1 commit b8d7e27

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ These are the major functions that help in visual testing:
4444

4545
First one is the `seeVisualDiff` which basically takes two parameters
4646
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.
47-
2) `options` options can be passed which include `prepaseBaseImage` and `tolerance`.
47+
2) `options` options can be passed which include `prepaseBaseImage`, `tolerance` and `needsSameDimension`.
4848

4949
```js
5050
/**
5151
* Check Visual Difference for Base and Screenshot Image
5252
* @param baseImage Name of the Base Image (Base Image path is taken from Configuration)
53-
* @param options Options ex {prepareBaseImage: true, tolerance: 5} along with Resemble JS Options, read more here: https://github.com/rsmbl/Resemble.js
53+
* @param options Options ex {prepareBaseImage: true, tolerance: 5, needsSameDimension: false} along with Resemble JS Options, read more here: https://github.com/rsmbl/Resemble.js
5454
* @returns {Promise<void>}
5555
*/
5656
async seeVisualDiff(baseImage, options) {}

index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,12 @@ class ResembleHelper extends Helper {
7878

7979
return new Promise((resolve, reject) => {
8080

81-
if (!options.outputSettings) {
81+
if (options.outputSettings) {
8282
options.outputSettings = {};
8383
}
84+
if (typeof options.needsSameDimension === 'undefined') {
85+
options.needsSameDimension = true;
86+
}
8487
resemble.outputSettings({
8588
boundingBox: options.boundingBox,
8689
ignoredBox: options.ignoredBox,
@@ -94,7 +97,7 @@ class ResembleHelper extends Helper {
9497
if (err) {
9598
reject(err);
9699
} else {
97-
if (!data.isSameDimensions) {
100+
if (options.needsSameDimension && !data.isSameDimensions) {
98101
let dimensions1 = sizeOf(baseImage);
99102
let dimensions2 = sizeOf(actualImage);
100103
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.`));

0 commit comments

Comments
 (0)