@wdio/visual-service 8.0.1 → 8.0.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,60 @@
1
1
  # @wdio/visual-service
2
2
 
3
+ ## 8.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 2f9ec42: ## 🐛 Bug-fixes
8
+
9
+ ### #967: Emulated device crops with `enableLegacyScreenshotMethod` set to `true` are not correct
10
+
11
+ When a screenshot of an emulated device is taken, but the browser was initially started as a "desktop" session, so not with emulated caps, and the `enableLegacyScreenshotMethod` property is set to `true`, the DPR of the emulated device is taken. This resulted in incorrect crop. We now store the original dpr and use that for the crop when it's an emulated device and started as a desktop browser session.
12
+
13
+ ## BiDi Fullpage screenshots for emulated device are broken
14
+
15
+ The BiDi fullpage screenshot for an emulated device is broken in the driver. We now fallback to the legacy screenshot method for BiDi and emulated devices
16
+
17
+ ## 💅 Polish
18
+
19
+ - Updated the multiple interfaces to use JS-Doc for better docs
20
+ - When `createJsonReportFiles` is set to `true` and there are a lot of differences we kept waiting. We now limited that to check a max of 5M diff-pixels or a diff threshold of 20%. If it's bigger the report will show a full coverage and extra logs are shown in the WDIO logs, something like this
21
+
22
+ ```logs
23
+ [0-0] 2025-05-24T06:02:18.887Z INFO @wdio/visual-service:webdriver-image-comparison:pixelDiffProcessing: Processing diff pixels started
24
+ [0-0] 2025-05-24T06:02:18.888Z INFO @wdio/visual-service:webdriver-image-comparison:pixelDiffProcessing: Processing 20143900 diff pixels
25
+ [0-0] 2025-05-24T06:02:19.770Z INFO @wdio/visual-service:webdriver-image-comparison:pixelDiffProcessing: Total pixels in image: 52,184,160
26
+ [0-0] 2025-05-24T06:02:19.770Z INFO @wdio/visual-service:webdriver-image-comparison:pixelDiffProcessing: Number of diff pixels: 20,143,900
27
+ [0-0] 2025-05-24T06:02:19.770Z INFO @wdio/visual-service:webdriver-image-comparison:pixelDiffProcessing: Diff percentage: 38.60%
28
+ [0-0] 2025-05-24T06:02:19.770Z ERROR @wdio/visual-service:webdriver-image-comparison:pixelDiffProcessing: Too many differences detected! Diff percentage: 38.60%, Diff pixels: 20,143,900
29
+ [0-0] 2025-05-24T06:02:19.771Z ERROR @wdio/visual-service:webdriver-image-comparison:pixelDiffProcessing: This likely indicates a major visual difference or an issue with the comparison.
30
+ [0-0] 2025-05-24T06:02:19.771Z ERROR @wdio/visual-service:webdriver-image-comparison:pixelDiffProcessing: Consider checking if the baseline image is correct or if there are major UI changes.
31
+ ```
32
+
33
+ ## Committers: 1
34
+
35
+ - Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
36
+
37
+ - Updated dependencies [2f9ec42]
38
+ - webdriver-image-comparison@9.0.3
39
+
40
+ ## 8.0.2
41
+
42
+ ### Patch Changes
43
+
44
+ - 9363467: ## 🐛 Bug-fixes
45
+
46
+ - #946: Visual Regression Changes in WDIO v9
47
+ - Fixed screen size detection in emulated mode for filenames. Previously used incorrect browser window size.
48
+ - Fixed screenshot behavior when `enableLegacyScreenshotMethod: true`, now correctly captures emulated screen instead of complete screen.
49
+ - Fixed emulated device handling for Chrome and Edge browsers, now properly sets device metrics based on `deviceMetrics` or `deviceName` capabilities.
50
+
51
+ ## Committers: 1
52
+
53
+ - Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
54
+
55
+ - Updated dependencies [9363467]
56
+ - webdriver-image-comparison@9.0.2
57
+
3
58
  ## 8.0.1
4
59
 
5
60
  ### Patch Changes
@@ -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,4BAA4B,CAAA;AAkBnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAepD,M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,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;IAqctC,IAAI,cAAc,IAAI,cAAc,CAKnC;CAyCJ"}
package/dist/service.js CHANGED
@@ -48,6 +48,11 @@ export default class WdioImageComparisonService extends BaseClass {
48
48
  else {
49
49
  await this.#extendMultiremoteBrowser(capabilities);
50
50
  }
51
+ // There is an issue with the emulation mode for Chrome or Edge with WebdriverIO v9
52
+ // It doesn't set the correct emulation mode for the browser based on the capabilities
53
+ // So we need to set the emulation mode manually
54
+ // this is a temporary fix until the issue is fixed in WebdriverIO v9 and enough users have upgraded to the latest version
55
+ await this.#setEmulation(this.#browser, capabilities);
51
56
  /**
52
57
  * add custom matcher for visual comparison when expect has been added.
53
58
  * this is not the case in standalone mode
@@ -424,4 +429,36 @@ export default class WdioImageComparisonService extends BaseClass {
424
429
  }
425
430
  return this._contextManager;
426
431
  }
432
+ async #setEmulationForBrowser(browserInstance, capabilities) {
433
+ if (!browserInstance.isBidi) {
434
+ return;
435
+ }
436
+ const chromeMobileEmulation = capabilities['goog:chromeOptions']?.mobileEmulation;
437
+ const edgeMobileEmulation = capabilities['ms:edgeOptions']?.mobileEmulation;
438
+ const mobileEmulation = chromeMobileEmulation || edgeMobileEmulation;
439
+ if (!mobileEmulation) {
440
+ return;
441
+ }
442
+ const { deviceName, deviceMetrics } = mobileEmulation;
443
+ if (deviceName) {
444
+ await browserInstance.emulate('device', deviceName);
445
+ return;
446
+ }
447
+ const { pixelRatio: devicePixelRatio = 1, width = 320, height = 658 } = deviceMetrics || {};
448
+ await browserInstance.browsingContextSetViewport({
449
+ context: await browserInstance.getWindowHandle(),
450
+ devicePixelRatio,
451
+ viewport: { width, height }
452
+ });
453
+ }
454
+ async #setEmulation(browser, capabilities) {
455
+ if (browser.isMultiremote) {
456
+ const multiremoteBrowser = browser;
457
+ for (const browserInstance of Object.values(multiremoteBrowser)) {
458
+ await this.#setEmulationForBrowser(browserInstance, browserInstance.capabilities);
459
+ }
460
+ return;
461
+ }
462
+ await this.#setEmulationForBrowser(browser, capabilities);
463
+ }
427
464
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACpF,OAAO,KAAK,EACR,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EAIzB,MAAM,YAAY,CAAA;AAEnB;;;;;GAKG;AAEH,wBAAgB,UAAU,CACtB,aAAa,EAAE,sBAAsB,EACrC,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,MAAM,GACxB,OAAO,CAMT;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,iBAAiB,SAAI,GAAG;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB,CAKA;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE;IAAC,MAAM,EAAC,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,GAAG,MAAM,CAOhH;AAiGD;;GAEG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,WAAW,CAAC,YAAY,GAAG,GAAG,GAAG,SAAS,CAMpF;AAmCD;;GAEG;AACH,wBAAsB,eAAe,CAAC,EAClC,cAAc,EACd,uBAAuB,EACvB,eAAe,EAClB,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CAgEhD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CA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,CAAA;CAAC,GAAG,MAAM,CAOhH;AAiGD;;GAEG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,WAAW,CAAC,YAAY,GAAG,GAAG,GAAG,SAAS,CAMpF;AAmCD;;GAEG;AACH,wBAAsB,eAAe,CAAC,EAClC,cAAc,EACd,uBAAuB,EACvB,eAAe,EAClB,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CAoEhD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAGtG;AAOD,wBAAgB,gBAAgB,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EACvD;IAAE,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GAC9D,OAAO,CAuBT;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC7B,EACI,WAAW,EACX,kBAAkB,EAAE,EAChB,SAAS,EACT,MAAM,EACN,KAAK,GACR,EACD,YAAY,EAAE,EACV,OAAO,EACP,WAAW,EACX,cAAc,EACd,UAAU,EACV,SAAS,EACT,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,eAAe,GAClB,EACD,GAAG,GACN,EAAE,wBAAwB,GAAG,WAAW,CAuB5C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,GAAG,OAAO,CAK9E"}
package/dist/utils.js CHANGED
@@ -160,7 +160,10 @@ export async function getInstanceData({ currentBrowser, initialDeviceRectangles,
160
160
  // Generic data
161
161
  const browserName = rawBrowserName === '' ? NOT_KNOWN : rawBrowserName.toLowerCase();
162
162
  const browserVersion = rawBrowserVersion === '' ? NOT_KNOWN : rawBrowserVersion.toLowerCase();
163
- let devicePixelRatio = 1;
163
+ // For #967: When a screenshot of an emulated device is taken, but the browser was initially
164
+ // started as a "desktop" session, so not with emulated caps, we need to store the initial
165
+ // devicePixelRatio when we take a screenshot and enableLegacyScreenshotMethod is enabled
166
+ let devicePixelRatio = !currentBrowser.isMobile ? (await currentBrowser.execute('return window.devicePixelRatio')) : 1;
164
167
  const platformName = rawPlatformName === '' ? NOT_KNOWN : rawPlatformName.toLowerCase();
165
168
  const logName = 'wdio-ics:options' in requestedCapabilities
166
169
  ? requestedCapabilities['wdio-ics:options']?.logName ?? ''
@@ -195,6 +198,7 @@ export async function getInstanceData({ currentBrowser, initialDeviceRectangles,
195
198
  deviceName,
196
199
  devicePixelRatio,
197
200
  deviceRectangles,
201
+ initialDevicePixelRatio: devicePixelRatio,
198
202
  isAndroid,
199
203
  isIOS,
200
204
  isMobile,
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": "8.0.1",
5
+ "version": "8.0.3",
6
6
  "license": "MIT",
7
7
  "homepage": "https://webdriver.io/docs/visual-testing",
8
8
  "repository": {
@@ -22,9 +22,9 @@
22
22
  "dependencies": {
23
23
  "@wdio/globals": "^9.13.0",
24
24
  "@wdio/logger": "^9.4.4",
25
- "@wdio/types": "^9.12.6",
25
+ "@wdio/types": "^9.14.0",
26
26
  "expect-webdriverio": "^5.1.0",
27
- "webdriver-image-comparison": "9.0.1"
27
+ "webdriver-image-comparison": "9.0.3"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "run-s clean build:*",