@wdio/visual-service 9.1.2 → 9.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/dist/matcher.d.ts.map +1 -1
- package/dist/matcher.js +19 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +12 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,69 @@
|
|
|
1
1
|
# @wdio/visual-service
|
|
2
2
|
|
|
3
|
+
## 9.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a3bc7a4: ## #1115 Respect `alwaysSaveActualImage: false` for `checkScreen` methods
|
|
8
|
+
|
|
9
|
+
When using visual matchers like `toMatchScreenSnapshot('tag', 0.9)` with `alwaysSaveActualImage: false`, the actual image was still being saved even when the comparison passed within the threshold.
|
|
10
|
+
|
|
11
|
+
The root cause was that the matcher's expected threshold was not being passed to the core comparison logic. The core used `saveAboveTolerance` (defaulting to 0) to decide whether to save images, while the matcher used the user-provided threshold to determine pass/fail - these were disconnected.
|
|
12
|
+
|
|
13
|
+
This fix ensures:
|
|
14
|
+
|
|
15
|
+
- When `alwaysSaveActualImage: false` and `saveAboveTolerance` is not explicitly set, actual images are never saved (respecting the literal meaning of the option)
|
|
16
|
+
- When `saveAboveTolerance` is explicitly set (like matchers do internally), actual images are saved only when the mismatch exceeds that threshold
|
|
17
|
+
|
|
18
|
+
# Committers: 1
|
|
19
|
+
|
|
20
|
+
- Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
|
|
21
|
+
|
|
22
|
+
- a3bc7a4: ## Fix: `save*` methods now always save files regardless of `alwaysSaveActualImage` setting
|
|
23
|
+
|
|
24
|
+
Previously, when `alwaysSaveActualImage: false` was set in the configuration, `save*` methods (`saveScreen`, `saveElement`, `saveFullPageScreen`, `saveAppScreen`, `saveAppElement`) were not saving files to disk, causing test failures.
|
|
25
|
+
|
|
26
|
+
The `alwaysSaveActualImage` option is intended to control whether actual images are saved during `check*` methods (comparison operations), not `save*` methods. Since `save*` methods are explicitly designed to save screenshots, they should always save files regardless of this setting.
|
|
27
|
+
|
|
28
|
+
This fix ensures:
|
|
29
|
+
|
|
30
|
+
- `save*` methods always save files to disk, even when `alwaysSaveActualImage: false` is set in the config
|
|
31
|
+
- `alwaysSaveActualImage: false` continues to work correctly for `check*` methods (as intended for issue #1115)
|
|
32
|
+
- The behavior is now consistent: `save*` = always save, `check*` = respect `alwaysSaveActualImage` setting
|
|
33
|
+
|
|
34
|
+
**Implementation details:**
|
|
35
|
+
|
|
36
|
+
- The visual service overrides `alwaysSaveActualImage: true` when calling `save*` methods directly from the browser API
|
|
37
|
+
- `save*` methods respect whatever `alwaysSaveActualImage` value is passed to them (no special logic needed)
|
|
38
|
+
- `check*` methods pass through the config value (which may be `false`), so `save*` methods respect it when called internally
|
|
39
|
+
- This clean separation ensures `save*` methods work correctly when called directly while still respecting `alwaysSaveActualImage` for `check*` methods
|
|
40
|
+
|
|
41
|
+
# Committers: 1
|
|
42
|
+
|
|
43
|
+
- Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [a3bc7a4]
|
|
46
|
+
- Updated dependencies [a3bc7a4]
|
|
47
|
+
- @wdio/image-comparison-core@1.1.3
|
|
48
|
+
|
|
49
|
+
## 9.1.3
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- 2a518ff: # 🐛 Bugfixes
|
|
54
|
+
|
|
55
|
+
## #1111 Pass matcher threshold to core as saveAboveTolerance
|
|
56
|
+
|
|
57
|
+
When using visual matchers like `toMatchScreenSnapshot('tag', 0.9)` with `alwaysSaveActualImage: false`, the actual image was still being saved even when the comparison passed within the threshold.
|
|
58
|
+
|
|
59
|
+
The root cause was that the matcher's expected threshold was not being passed to the core comparison logic. The core used `saveAboveTolerance` (defaulting to 0) to decide whether to save images, while the matcher used the user-provided threshold to determine pass/fail - these were disconnected.
|
|
60
|
+
|
|
61
|
+
This fix ensures the matcher passes the expected threshold to the core as `saveAboveTolerance`, so images are only saved when the mismatch actually exceeds the user's acceptable threshold.
|
|
62
|
+
|
|
63
|
+
# Committers: 1
|
|
64
|
+
|
|
65
|
+
- Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
|
|
66
|
+
|
|
3
67
|
## 9.1.2
|
|
4
68
|
|
|
5
69
|
### Patch Changes
|
package/dist/matcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../src/matcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,8BAA8B,EAC9B,6BAA6B,EAC7B,4BAA4B,EAC/B,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../src/matcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,8BAA8B,EAC9B,6BAA6B,EAC7B,4BAA4B,EAC/B,MAAM,YAAY,CAAA;AAwInB,wBAAsB,qBAAqB,CACvC,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,EAC7D,GAAG,EAAE,MAAM,EACX,uBAAuB,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC,cAAc,CAAC,MAAM,CAAC,EAC3E,kBAAkB,CAAC,EAAE,4BAA4B;;;GAKpD;AAED,wBAAsB,uBAAuB,CACzC,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,EAC7D,GAAG,EAAE,MAAM,EACX,uBAAuB,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC,cAAc,CAAC,MAAM,CAAC,EAC3E,kBAAkB,CAAC,EAAE,8BAA8B;;;GAKtD;AAED,wBAAsB,sBAAsB,CACxC,OAAO,EAAE,WAAW,CAAC,OAAO,EAC5B,GAAG,EAAE,MAAM,EACX,uBAAuB,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC,cAAc,CAAC,MAAM,CAAC,EAC3E,kBAAkB,CAAC,EAAE,6BAA6B;;;GAMrD;AAED,wBAAsB,2BAA2B,CAC7C,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,EAC7D,GAAG,EAAE,MAAM,EACX,uBAAuB,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC,cAAc,CAAC,MAAM,CAAC,EAC3E,kBAAkB,CAAC,EAAE,8BAA8B;;;GAKtD"}
|
package/dist/matcher.js
CHANGED
|
@@ -82,6 +82,25 @@ function parseMatcherParams(tag, expectedResult, options) {
|
|
|
82
82
|
* overwrite `returnAllCompareData` to allow us to provide a better assertion message
|
|
83
83
|
*/
|
|
84
84
|
options.returnAllCompareData = true;
|
|
85
|
+
/**
|
|
86
|
+
* Pass the expected threshold to the core as `saveAboveTolerance` so it knows
|
|
87
|
+
* when to save actual images (only when mismatch exceeds the threshold).
|
|
88
|
+
* This ensures that when `alwaysSaveActualImage: false`, images are not saved
|
|
89
|
+
* if the comparison passes within the user's acceptable threshold.
|
|
90
|
+
* Only set if user hasn't explicitly set saveAboveTolerance.
|
|
91
|
+
* For numeric thresholds, use that value; otherwise default to 0 (same as comparison default).
|
|
92
|
+
* @see https://github.com/webdriverio/visual-testing/issues/1111
|
|
93
|
+
*/
|
|
94
|
+
if (options.saveAboveTolerance === undefined) {
|
|
95
|
+
// Only set saveAboveTolerance for numeric thresholds (including undefined which defaults to 0)
|
|
96
|
+
// Asymmetric matchers can't be converted to a numeric tolerance
|
|
97
|
+
if (typeof expectedResult === 'number') {
|
|
98
|
+
options.saveAboveTolerance = expectedResult;
|
|
99
|
+
}
|
|
100
|
+
else if (expectedResult === undefined) {
|
|
101
|
+
options.saveAboveTolerance = DEFAULT_EXPECTED_RESULT;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
85
104
|
return { expectedResult, options };
|
|
86
105
|
}
|
|
87
106
|
export async function toMatchScreenSnapshot(browser, tag, expectedResultOrOptions, optionsOrUndefined) {
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EACH,SAAS,EAWZ,MAAM,6BAA6B,CAAA;AAiBpC,OAAO,KAAK,EAAc,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAepD,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,SAAS;;IAM7D,OAAO,CAAC,eAAe,CAAC,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAC,CAAyC;gBAEtD,OAAO,EAAE,oBAAoB,EAAE,CAAC,EAAE,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM;IAMlG;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB;IAIzE,MAAM,CACR,YAAY,EAAE,WAAW,CAAC,YAAY,EACtC,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB;IAgC3D,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI;IAOtC,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EACH,SAAS,EAWZ,MAAM,6BAA6B,CAAA;AAiBpC,OAAO,KAAK,EAAc,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAepD,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,SAAS;;IAM7D,OAAO,CAAC,eAAe,CAAC,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAC,CAAyC;gBAEtD,OAAO,EAAE,oBAAoB,EAAE,CAAC,EAAE,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM;IAMlG;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB;IAIzE,MAAM,CACR,YAAY,EAAE,WAAW,CAAC,YAAY,EACtC,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB;IAgC3D,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI;IAOtC,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK;IAwatC,IAAI,cAAc,IAAI,cAAc,CAKnC;CAyCJ"}
|
package/dist/service.js
CHANGED
|
@@ -162,6 +162,11 @@ export default class WdioImageComparisonService extends BaseClass {
|
|
|
162
162
|
deviceRectangles: self.contextManager.getViewportContext(),
|
|
163
163
|
};
|
|
164
164
|
const isCurrentContextNative = self.contextManager.isNativeContext;
|
|
165
|
+
// save* methods should always save files, regardless of alwaysSaveActualImage config
|
|
166
|
+
const isSaveCommand = commandName === 'saveElement';
|
|
167
|
+
const wicOptions = isSaveCommand
|
|
168
|
+
? { ...self.defaultOptions, alwaysSaveActualImage: true }
|
|
169
|
+
: self.defaultOptions;
|
|
165
170
|
return [{
|
|
166
171
|
browserInstance,
|
|
167
172
|
element,
|
|
@@ -170,7 +175,7 @@ export default class WdioImageComparisonService extends BaseClass {
|
|
|
170
175
|
isNativeContext: isCurrentContextNative,
|
|
171
176
|
tag,
|
|
172
177
|
[elementOptionsKey]: {
|
|
173
|
-
wic:
|
|
178
|
+
wic: wicOptions,
|
|
174
179
|
method: elementOptions,
|
|
175
180
|
},
|
|
176
181
|
testContext: enrichTestContext({
|
|
@@ -207,6 +212,11 @@ export default class WdioImageComparisonService extends BaseClass {
|
|
|
207
212
|
deviceRectangles: self.contextManager.getViewportContext()
|
|
208
213
|
};
|
|
209
214
|
const isCurrentContextNative = self.contextManager.isNativeContext;
|
|
215
|
+
// save* methods should always save files, regardless of alwaysSaveActualImage config
|
|
216
|
+
const isSaveCommand = commandName === 'saveScreen' || commandName === 'saveFullPageScreen' || commandName === 'saveTabbablePage';
|
|
217
|
+
const wicOptions = isSaveCommand
|
|
218
|
+
? { ...self.defaultOptions, alwaysSaveActualImage: true }
|
|
219
|
+
: self.defaultOptions;
|
|
210
220
|
return [{
|
|
211
221
|
browserInstance,
|
|
212
222
|
folders: getFolders(pageOptions, self.folders, self.#getBaselineFolder()),
|
|
@@ -214,7 +224,7 @@ export default class WdioImageComparisonService extends BaseClass {
|
|
|
214
224
|
isNativeContext: isCurrentContextNative,
|
|
215
225
|
tag,
|
|
216
226
|
[pageOptionsKey]: {
|
|
217
|
-
wic:
|
|
227
|
+
wic: wicOptions,
|
|
218
228
|
method: pageOptions,
|
|
219
229
|
},
|
|
220
230
|
testContext: enrichTestContext({
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@wdio/visual-service",
|
|
3
3
|
"author": "Wim Selles - wswebcreation",
|
|
4
4
|
"description": "Image comparison / visual regression testing for WebdriverIO",
|
|
5
|
-
"version": "9.1.
|
|
5
|
+
"version": "9.1.4",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://webdriver.io/docs/visual-testing",
|
|
8
8
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@wdio/logger": "^9.18.0",
|
|
25
25
|
"@wdio/types": "^9.20.0",
|
|
26
26
|
"expect-webdriverio": "^5.6.1",
|
|
27
|
-
"@wdio/image-comparison-core": "1.1.
|
|
27
|
+
"@wdio/image-comparison-core": "1.1.3"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "run-s clean build:*",
|