Skip to content

Commit c0d999e

Browse files
yankydooJANK Michael
and
JANK Michael
authored
passing through output settings to resemble.js (#59)
Co-authored-by: JANK Michael <[email protected]>
1 parent e8a87df commit c0d999e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Scenario('Compare CPU Usage Images', async (I) => {
108108
### Ignored Box
109109
You can also exclude part of the image from comparison, by specifying the excluded area in pixels from the top left.
110110
Just declare an object and pass it in options as `ignoredBox`:
111-
```
111+
```js
112112
const box = {
113113
left: 0,
114114
top: 10,
@@ -121,6 +121,19 @@ I.seeVisualDiff("image.png", {prepareBaseImage: true, tolerance: 1, ignoredBox:
121121
After this, that specific mentioned part will be ignored while comparison.
122122
This works for `seeVisualDiff` and `seeVisualDiffForElement`.
123123

124+
### resemble.js Output Settings
125+
You can set further output settings used by resemble.js. Declare an object specifying them and pass it in the options as `outputSettings`:
126+
127+
```js
128+
const outputSettings = {
129+
ignoreAreasColoredWith: {r: 250, g: 250, b: 250, a: 0},
130+
// read more here: https://github.com/rsmbl/Resemble.js
131+
};
132+
I.seeVisualDiff("image.png", {prepareBaseImage: true, tolerance: 1, outputSettings: outputSettings});
133+
```
134+
135+
Refer to the [resemble.js](https://github.com/rsmbl/Resemble.js) documentation for available output settings.
136+
124137
### Skip Failure
125138
You can avoid the test fails for a given threshold but yet generates the difference image.
126139
Just declare an object and pass it in options as `skipFailure`:
@@ -130,6 +143,7 @@ I.seeVisualDiff("image.png", {prepareBaseImage: true, tolerance: 1, skipFailure:
130143
After this, the system generates the difference image but does not fail the test.
131144
This works for `seeVisualDiff` and `seeVisualDiffForElement`.
132145

146+
133147
### Allure Reporter
134148
Allure reports may also be generated directly from the tool. To do so, add
135149

index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ class ResembleHelper extends Helper {
5858

5959
return new Promise((resolve, reject) => {
6060

61+
if (!options.outputSettings) {
62+
options.outputSettings = {};
63+
}
6164
resemble.outputSettings({
6265
boundingBox: options.boundingBox,
63-
ignoredBox: options.ignoredBox
66+
ignoredBox: options.ignoredBox,
67+
...options.outputSettings,
6468
});
6569

6670
this.debug("Tolerance Level Provided " + options.tolerance);

0 commit comments

Comments
 (0)