@wdio/visual-service 3.0.2 → 3.1.0

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,20 @@
1
1
  # @wdio/visual-service
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 43ed502: Add font loading features:
8
+ - add `waitForFontsLoaded` so the module automatically waits for all fonts to be loaded, enabled by default
9
+ - add `enableLayoutTesting` so all text will become transparent so
10
+ - font rendering issues won't cause flakiness
11
+ - image comparison can be done on layout
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [43ed502]
16
+ - webdriver-image-comparison@4.1.0
17
+
3
18
  ## 3.0.2
4
19
 
5
20
  ### Patch Changes
package/dist/service.d.ts CHANGED
@@ -6,6 +6,10 @@ export default class WdioImageComparisonService extends BaseClass {
6
6
  private _browser?;
7
7
  private _isNativeContext;
8
8
  constructor(options: ClassOptions, _: WebdriverIO.Capabilities, config: WebdriverIO.Config);
9
+ /**
10
+ * Set up the service if users want to use it in standalone mode
11
+ */
12
+ remoteSetup(browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): Promise<void>;
9
13
  before(capabilities: WebdriverIO.Capabilities, _specs: string[], browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): Promise<void>;
10
14
  beforeTest(test: Frameworks.Test): void;
11
15
  afterCommand(commandName: string, _args: string[], result: number | string, error: any): void;
@@ -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,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EACH,SAAS,EAUZ,MAAM,4BAA4B,CAAA;AAqBnC,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,SAAS;;IAI7D,OAAO,C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AAY,CAAE,WAAW,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,EAAE,MAAM,EAAC,MAAM,GAAC,MAAM,EAAE,KAAK,EAAC,GAAG;CA+HpF"}
package/dist/service.js CHANGED
@@ -25,6 +25,12 @@ export default class WdioImageComparisonService extends BaseClass {
25
25
  this.#config = config;
26
26
  this._isNativeContext = undefined;
27
27
  }
28
+ /**
29
+ * Set up the service if users want to use it in standalone mode
30
+ */
31
+ async remoteSetup(browser) {
32
+ await this.before(browser.capabilities, [], browser);
33
+ }
28
34
  async before(capabilities, _specs, browser) {
29
35
  this._browser = browser;
30
36
  this._isNativeContext = determineNativeContext(this._browser);
@@ -36,14 +42,20 @@ export default class WdioImageComparisonService extends BaseClass {
36
42
  await this.#extendMultiremoteBrowser(capabilities);
37
43
  }
38
44
  /**
39
- * add custom matcher for visual comparison
45
+ * add custom matcher for visual comparison when expect has been added.
46
+ * this is not the case in standalone mode
40
47
  */
41
- expect.extend({
42
- toMatchScreenSnapshot,
43
- toMatchFullPageSnapshot,
44
- toMatchElementSnapshot,
45
- toMatchTabbablePageSnapshot,
46
- });
48
+ try {
49
+ expect.extend({
50
+ toMatchScreenSnapshot,
51
+ toMatchFullPageSnapshot,
52
+ toMatchElementSnapshot,
53
+ toMatchTabbablePageSnapshot,
54
+ });
55
+ }
56
+ catch (err) {
57
+ log.warn('Expect package not found. This means that the custom matchers `toMatchScreenSnapshot|toMatchFullPageSnapshot|toMatchElementSnapshot|toMatchTabbablePageSnapshot` are not added and can not be used. Please make sure to add it to your `package.json` if you want to use the Visual custom matchers.');
58
+ }
47
59
  }
48
60
  beforeTest(test) {
49
61
  this.#currentFile = test.file;
@@ -57,15 +69,17 @@ export default class WdioImageComparisonService extends BaseClass {
57
69
  }
58
70
  #getBaselineFolder() {
59
71
  const isDefaultBaselineFolder = normalize(FOLDERS.DEFAULT.BASE) === this.folders.baselineFolder;
60
- const baselineFolder = (isDefaultBaselineFolder ? this.#currentFilePath : this.folders.baselineFolder);
72
+ const baselineFolder = (isDefaultBaselineFolder && this.#currentFilePath ? this.#currentFilePath : this.folders.baselineFolder);
61
73
  /**
62
74
  * support `resolveSnapshotPath` WebdriverIO option
63
75
  * @ref https://webdriver.io/docs/configuration#resolvesnapshotpath
64
76
  *
65
77
  * We only use this option if the baselineFolder is the default one, otherwise the
66
78
  * service option for setting the baselineFolder should be used
79
+ *
80
+ * We also check `this.#config` because for standalone usage of the service, the config is not available
67
81
  */
68
- if (typeof this.#config.resolveSnapshotPath === 'function' && this.#currentFile && isDefaultBaselineFolder) {
82
+ if (this.#config && typeof this.#config.resolveSnapshotPath === 'function' && this.#currentFile && isDefaultBaselineFolder) {
69
83
  return this.#config.resolveSnapshotPath(this.#currentFile, '.png');
70
84
  }
71
85
  return baselineFolder;
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": "3.0.2",
5
+ "version": "3.1.0",
6
6
  "license": "MIT",
7
7
  "homepage": "https://webdriver.io/docs/visual-testing",
8
8
  "repository": {
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "@wdio/logger": "^8.24.12",
24
24
  "@wdio/types": "^8.26.2",
25
- "webdriver-image-comparison": "^4.0.2"
25
+ "webdriver-image-comparison": "^4.1.0"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "run-s clean build:*",