@wdio/visual-service 2.0.0 → 3.0.1
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 +20 -0
- package/dist/service.d.ts +3 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +28 -4
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @wdio/visual-service
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c8fdcd3: Fix to override visibility/display value
|
|
8
|
+
- Updated dependencies [c8fdcd3]
|
|
9
|
+
- webdriver-image-comparison@4.0.2
|
|
10
|
+
|
|
11
|
+
## 3.0.0
|
|
12
|
+
|
|
13
|
+
### Major Changes
|
|
14
|
+
|
|
15
|
+
- fd74a35: (feat): set default baseline folder next to test file
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- e93a878: fix default snapshot path to be overwritten through method/service options
|
|
20
|
+
- Updated dependencies [fd74a35]
|
|
21
|
+
- webdriver-image-comparison@4.0.1
|
|
22
|
+
|
|
3
23
|
## 2.0.0
|
|
4
24
|
|
|
5
25
|
### Major Changes
|
package/dist/service.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import type { Frameworks } from '@wdio/types';
|
|
1
2
|
import type { ClassOptions } from 'webdriver-image-comparison';
|
|
2
3
|
import { BaseClass } from 'webdriver-image-comparison';
|
|
3
4
|
export default class WdioImageComparisonService extends BaseClass {
|
|
4
5
|
#private;
|
|
5
6
|
private _browser?;
|
|
6
7
|
private _isNativeContext;
|
|
7
|
-
constructor(options: ClassOptions);
|
|
8
|
+
constructor(options: ClassOptions, _: WebdriverIO.Capabilities, config: WebdriverIO.Config);
|
|
8
9
|
before(capabilities: WebdriverIO.Capabilities, _specs: string[], browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): Promise<void>;
|
|
10
|
+
beforeTest(test: Frameworks.Test): void;
|
|
9
11
|
afterCommand(commandName: string, _args: string[], result: number | string, error: any): void;
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=service.d.ts.map
|
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,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EACH,SAAS,
|
|
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,CAAC,QAAQ,CAAC,CAAsD;IACvE,OAAO,CAAC,gBAAgB,CAAqB;gBAEjC,OAAO,EAAE,YAAY,EAAE,CAAC,EAAE,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM;IAMpF,MAAM,CACR,YAAY,EAAE,WAAW,CAAC,YAAY,EACtC,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB;IAuBjE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI;IAKhC,YAAY,CAAE,WAAW,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,EAAE,MAAM,EAAC,MAAM,GAAC,MAAM,EAAE,KAAK,EAAC,GAAG;CA6HpF"}
|
package/dist/service.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import logger from '@wdio/logger';
|
|
2
2
|
import { expect } from '@wdio/globals';
|
|
3
|
-
import {
|
|
3
|
+
import { dirname, normalize, resolve } from 'node:path';
|
|
4
|
+
import { BaseClass, checkElement, checkFullPageScreen, checkScreen, saveElement, saveFullPageScreen, saveScreen, saveTabbablePage, checkTabbablePage, FOLDERS, } from 'webdriver-image-comparison';
|
|
4
5
|
import { determineNativeContext, getFolders, getInstanceData } from './utils.js';
|
|
5
6
|
import { toMatchScreenSnapshot, toMatchFullPageSnapshot, toMatchElementSnapshot, toMatchTabbablePageSnapshot } from './matcher.js';
|
|
6
7
|
const log = logger('@wdio/visual-service');
|
|
@@ -14,10 +15,14 @@ const pageCommands = {
|
|
|
14
15
|
checkTabbablePage,
|
|
15
16
|
};
|
|
16
17
|
export default class WdioImageComparisonService extends BaseClass {
|
|
18
|
+
#config;
|
|
19
|
+
#currentFile;
|
|
20
|
+
#currentFilePath;
|
|
17
21
|
_browser;
|
|
18
22
|
_isNativeContext;
|
|
19
|
-
constructor(options) {
|
|
23
|
+
constructor(options, _, config) {
|
|
20
24
|
super(options);
|
|
25
|
+
this.#config = config;
|
|
21
26
|
this._isNativeContext = undefined;
|
|
22
27
|
}
|
|
23
28
|
async before(capabilities, _specs, browser) {
|
|
@@ -40,12 +45,31 @@ export default class WdioImageComparisonService extends BaseClass {
|
|
|
40
45
|
toMatchTabbablePageSnapshot,
|
|
41
46
|
});
|
|
42
47
|
}
|
|
48
|
+
beforeTest(test) {
|
|
49
|
+
this.#currentFile = test.file;
|
|
50
|
+
this.#currentFilePath = resolve(dirname(test.file), FOLDERS.DEFAULT.BASE);
|
|
51
|
+
}
|
|
43
52
|
afterCommand(commandName, _args, result, error) {
|
|
44
53
|
// This is for the cases where in the E2E tests we switch to a WEBVIEW or back to NATIVE_APP context
|
|
45
54
|
if (commandName === 'getContext' && error === undefined && typeof result === 'string') {
|
|
46
55
|
this._isNativeContext = result.includes('NATIVE');
|
|
47
56
|
}
|
|
48
57
|
}
|
|
58
|
+
#getBaselineFolder() {
|
|
59
|
+
const isDefaultBaselineFolder = normalize(FOLDERS.DEFAULT.BASE) === this.folders.baselineFolder;
|
|
60
|
+
const baselineFolder = (isDefaultBaselineFolder ? this.#currentFilePath : this.folders.baselineFolder);
|
|
61
|
+
/**
|
|
62
|
+
* support `resolveSnapshotPath` WebdriverIO option
|
|
63
|
+
* @ref https://webdriver.io/docs/configuration#resolvesnapshotpath
|
|
64
|
+
*
|
|
65
|
+
* We only use this option if the baselineFolder is the default one, otherwise the
|
|
66
|
+
* service option for setting the baselineFolder should be used
|
|
67
|
+
*/
|
|
68
|
+
if (typeof this.#config.resolveSnapshotPath === 'function' && this.#currentFile && isDefaultBaselineFolder) {
|
|
69
|
+
return this.#config.resolveSnapshotPath(this.#currentFile, '.png');
|
|
70
|
+
}
|
|
71
|
+
return baselineFolder;
|
|
72
|
+
}
|
|
49
73
|
async #extendMultiremoteBrowser(capabilities) {
|
|
50
74
|
const browser = this._browser;
|
|
51
75
|
const browserNames = Object.keys(capabilities);
|
|
@@ -89,7 +113,7 @@ export default class WdioImageComparisonService extends BaseClass {
|
|
|
89
113
|
},
|
|
90
114
|
getElementRect: this.getElementRect.bind(currentBrowser),
|
|
91
115
|
screenShot: this.takeScreenshot.bind(currentBrowser),
|
|
92
|
-
}, instanceData, getFolders(elementOptions, self.folders), element, tag, {
|
|
116
|
+
}, instanceData, getFolders(elementOptions, self.folders, self.#getBaselineFolder()), element, tag, {
|
|
93
117
|
wic: self.defaultOptions,
|
|
94
118
|
method: elementOptions,
|
|
95
119
|
}, self._isNativeContext);
|
|
@@ -104,7 +128,7 @@ export default class WdioImageComparisonService extends BaseClass {
|
|
|
104
128
|
},
|
|
105
129
|
getElementRect: this.getElementRect.bind(currentBrowser),
|
|
106
130
|
screenShot: this.takeScreenshot.bind(currentBrowser),
|
|
107
|
-
}, instanceData, getFolders(pageOptions, self.folders), tag, {
|
|
131
|
+
}, instanceData, getFolders(pageOptions, self.folders, self.#getBaselineFolder()), tag, {
|
|
108
132
|
wic: self.defaultOptions,
|
|
109
133
|
method: pageOptions,
|
|
110
134
|
}, self._isNativeContext);
|
package/dist/utils.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Folders, InstanceData, CheckScreenMethodOptions, SaveScreenMethodO
|
|
|
6
6
|
* Otherwise, use the values set during instantiation
|
|
7
7
|
*/
|
|
8
8
|
type getFolderMethodOptions = CheckElementMethodOptions | CheckFullPageMethodOptions | CheckScreenMethodOptions | SaveElementMethodOptions | SaveFullPageMethodOptions | SaveScreenMethodOptions;
|
|
9
|
-
export declare function getFolders(methodOptions: getFolderMethodOptions, folders: Folders): Folders;
|
|
9
|
+
export declare function getFolders(methodOptions: getFolderMethodOptions, folders: Folders, currentTestPath: string): Folders;
|
|
10
10
|
/**
|
|
11
11
|
* Get the size of a screenshot in pixels without the device pixel ratio
|
|
12
12
|
*/
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,OAAO,EACP,YAAY,EACZ,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EAC3B,MAAM,4BAA4B,CAAA;AAOnC;;;;;GAKG;AACH,KAAK,sBAAsB,GACrB,yBAAyB,GACzB,0BAA0B,GAC1B,wBAAwB,GACxB,wBAAwB,GACxB,yBAAyB,GACzB,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,OAAO,EACP,YAAY,EACZ,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EAC3B,MAAM,4BAA4B,CAAA;AAOnC;;;;;GAKG;AACH,KAAK,sBAAsB,GACrB,yBAAyB,GACzB,0BAA0B,GAC1B,wBAAwB,GACxB,wBAAwB,GACxB,yBAAyB,GACzB,uBAAuB,CAAC;AAE9B,wBAAgB,UAAU,CACtB,aAAa,EAAE,sBAAsB,EACrC,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,MAAM,GACxB,OAAO,CAMT;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,iBAAiB,SAAI,GAAG;IAC1E,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;AAkFD;;GAEG;AACH,wBAAsB,eAAe,CAAC,cAAc,EAAE,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CA+DhG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAGtG;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,GAC7D,OAAO,CAQT"}
|
package/dist/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IOS_OFFSETS } from 'webdriver-image-comparison';
|
|
2
|
-
export function getFolders(methodOptions, folders) {
|
|
2
|
+
export function getFolders(methodOptions, folders, currentTestPath) {
|
|
3
3
|
return {
|
|
4
4
|
actualFolder: methodOptions.actualFolder ?? folders.actualFolder,
|
|
5
|
-
baselineFolder: methodOptions.baselineFolder ??
|
|
5
|
+
baselineFolder: methodOptions.baselineFolder ?? currentTestPath,
|
|
6
6
|
diffFolder: methodOptions.diffFolder ?? folders.diffFolder,
|
|
7
7
|
};
|
|
8
8
|
}
|
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": "
|
|
5
|
+
"version": "3.0.1",
|
|
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.
|
|
25
|
+
"webdriver-image-comparison": "^4.0.2"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "run-s clean build:*",
|