Skip to content

Commit f98ec55

Browse files
jonataskJonatas Kirsch
andauthored
Issue #60 - Prepare all baselines of test by setting parameter in config (#65)
Co-authored-by: Jonatas Kirsch <[email protected]>
1 parent f2eb5b2 commit f98ec55

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# codeceptjs-resemblehelper
2-
Helper for resemble.js, used for image comparison in tests with WebdriverIO.
2+
Helper for resemble.js, used for image comparison in tests with WebdriverIO or Puppeteer.
33

44
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.
55

@@ -21,19 +21,25 @@ Example:
2121
"ResembleHelper" : {
2222
"require": "codeceptjs-resemblehelper",
2323
"baseFolder": "./tests/screenshots/base/",
24-
"diffFolder": "./tests/screenshots/diff/"
24+
"diffFolder": "./tests/screenshots/diff/",
25+
"prepareBaseImage": true
2526
}
2627
}
2728
}
2829
```
2930

30-
To use the Helper, users must provide the two parameters:
31+
To use the Helper, users may provide the parameters:
3132

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

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

36-
Usage, these are major functions that help in visual testing
37+
`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.
38+
39+
40+
### Usage
41+
42+
These are the major functions that help in visual testing:
3743

3844
First one is the `seeVisualDiff` which basically takes two parameters
3945
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.

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ResembleHelper extends Helper {
1919
this.baseFolder = this.resolvePath(config.baseFolder);
2020
this.diffFolder = this.resolvePath(config.diffFolder);
2121
this.screenshotFolder = global.output_dir + "/";
22+
this.prepareBaseImage = config.prepareBaseImage;
2223
}
2324

2425
resolvePath(folderPath) {
@@ -177,7 +178,7 @@ class ResembleHelper extends Helper {
177178
* @param region
178179
* @param bucketName
179180
* @param baseImage
180-
* @param ifBaseImage - tells if the prepareBaseImage is true or false. If false, then it won't upload the baseImage.
181+
* @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.
181182
* @returns {Promise<void>}
182183
*/
183184

@@ -296,6 +297,10 @@ class ResembleHelper extends Helper {
296297
options.tolerance = 0;
297298
}
298299

300+
if (this.prepareBaseImage) {
301+
options.prepareBaseImage = true;
302+
}
303+
299304
const awsC = this.config.aws;
300305

301306
if (awsC !== undefined && options.prepareBaseImage === false) {
@@ -426,4 +431,4 @@ class ResembleHelper extends Helper {
426431
}
427432
}
428433

429-
module.exports = ResembleHelper;
434+
module.exports = ResembleHelper;

0 commit comments

Comments
 (0)