Skip to content

Issue #60 - Prepare all baselines of test by setting parameter in config #65

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 1 commit into from
Apr 27, 2020
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
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# codeceptjs-resemblehelper
Helper for resemble.js, used for image comparison in tests with WebdriverIO.
Helper for resemble.js, used for image comparison in tests with WebdriverIO or Puppeteer.

codeceptjs-resemblehelper is a [CodeceptJS](https://codecept.io/) helper which can be used to compare screenshots and make the tests fail/pass based on the tolerance allowed.

Expand All @@ -21,19 +21,25 @@ Example:
"ResembleHelper" : {
"require": "codeceptjs-resemblehelper",
"baseFolder": "./tests/screenshots/base/",
"diffFolder": "./tests/screenshots/diff/"
"diffFolder": "./tests/screenshots/diff/",
"prepareBaseImage": true
}
}
}
```

To use the Helper, users must provide the two parameters:
To use the Helper, users may provide the parameters:

`baseFolder`: This is the folder for base images, which will be used with screenshot for comparison.
`baseFolder`: Mandatory. This is the folder for base images, which will be used with screenshot for comparison.

`diffFolder`: This will the folder where resemble would try to store the difference image, which can be viewed later.
`diffFolder`: Mandatory. This will the folder where resemble would try to store the difference image, which can be viewed later.

Usage, these are major functions that help in visual testing
`prepareBaseImage`: Optional. When `true` then the system replaces all of the baselines related to the test case(s) you ran. This is equivalent of setting the option `prepareBaseImage: true` in all verifications of the test file.


### Usage

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.
Expand Down
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ResembleHelper extends Helper {
this.baseFolder = this.resolvePath(config.baseFolder);
this.diffFolder = this.resolvePath(config.diffFolder);
this.screenshotFolder = global.output_dir + "/";
this.prepareBaseImage = config.prepareBaseImage;
}

resolvePath(folderPath) {
Expand Down Expand Up @@ -177,7 +178,7 @@ class ResembleHelper extends Helper {
* @param region
* @param bucketName
* @param baseImage
* @param ifBaseImage - tells if the prepareBaseImage is true or false. If false, then it won't upload the baseImage.
* @param ifBaseImage - tells if the prepareBaseImage is true or false. If false, then it won't upload the baseImage. However, this parameter is not considered if the config file has a prepareBaseImage set to true.
* @returns {Promise<void>}
*/

Expand Down Expand Up @@ -296,6 +297,10 @@ class ResembleHelper extends Helper {
options.tolerance = 0;
}

if (this.prepareBaseImage) {
options.prepareBaseImage = true;
}

const awsC = this.config.aws;

if (awsC !== undefined && options.prepareBaseImage === false) {
Expand Down Expand Up @@ -426,4 +431,4 @@ class ResembleHelper extends Helper {
}
}

module.exports = ResembleHelper;
module.exports = ResembleHelper;