Skip to content

[FEATURE] allow resemble.compare even if dimensions are not the same #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>}
*/
async seeVisualDiff(baseImage, options) {}
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.`));
Expand Down