@wdio/visual-service 9.1.2 → 9.1.3

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @wdio/visual-service
2
2
 
3
+ ## 9.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 2a518ff: # 🐛 Bugfixes
8
+
9
+ ## #1111 Pass matcher threshold to core as saveAboveTolerance
10
+
11
+ 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.
12
+
13
+ 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.
14
+
15
+ 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.
16
+
17
+ # Committers: 1
18
+
19
+ - Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
20
+
3
21
  ## 9.1.2
4
22
 
5
23
  ### Patch Changes
@@ -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;AAqHnB,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,uBA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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/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.2",
5
+ "version": "9.1.3",
6
6
  "license": "MIT",
7
7
  "homepage": "https://webdriver.io/docs/visual-testing",
8
8
  "repository": {