Skip to content

Commit 13e6e83

Browse files
committed
[FEATURE] allow resemble.compare even if dimensions are not the same \n\nsee codeceptjs#94
1 parent 3d9974d commit 13e6e83

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
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

+4-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class ResembleHelper extends Helper {
6363
if (!options.outputSettings) {
6464
options.outputSettings = {};
6565
}
66+
if (!options.needsSameDimension) {
67+
options.needsSameDimension = true;
68+
}
6669
resemble.outputSettings({
6770
boundingBox: options.boundingBox,
6871
ignoredBox: options.ignoredBox,
@@ -76,7 +79,7 @@ class ResembleHelper extends Helper {
7679
if (err) {
7780
reject(err);
7881
} else {
79-
if (!data.isSameDimensions) {
82+
if (options.needsSameDimension && !data.isSameDimensions) {
8083
let dimensions1 = sizeOf(baseImage);
8184
let dimensions2 = sizeOf(actualImage);
8285
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)