expect-webdriverio 5.2.0 → 5.2.2
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/lib/index.js +8 -2
- package/lib/matchers.js +31 -62
- package/lib/snapshot.js +6 -3
- package/lib/softAssertService.js +1 -1
- package/package.json +16 -16
- package/types/expect-webdriverio.d.ts +16 -8
package/lib/index.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { expect as expectLib } from 'expect';
|
|
2
|
-
import wdioMatchers from './matchers.js';
|
|
2
|
+
import * as wdioMatchers from './matchers.js';
|
|
3
3
|
import { DEFAULT_OPTIONS } from './constants.js';
|
|
4
4
|
import createSoftExpect from './softExpect.js';
|
|
5
5
|
import { SoftAssertService } from './softAssert.js';
|
|
6
6
|
export const matchers = new Map();
|
|
7
|
+
const filteredMatchers = {};
|
|
7
8
|
const extend = expectLib.extend;
|
|
9
|
+
Object.keys(wdioMatchers).forEach(matcher => {
|
|
10
|
+
if (typeof wdioMatchers[matcher] === 'function') {
|
|
11
|
+
filteredMatchers[matcher] = wdioMatchers[matcher];
|
|
12
|
+
}
|
|
13
|
+
});
|
|
8
14
|
expectLib.extend = (m) => {
|
|
9
15
|
if (!m || typeof m !== 'object') {
|
|
10
16
|
return;
|
|
@@ -12,7 +18,7 @@ expectLib.extend = (m) => {
|
|
|
12
18
|
Object.entries(m).forEach(([name, matcher]) => matchers.set(name, matcher));
|
|
13
19
|
return extend(m);
|
|
14
20
|
};
|
|
15
|
-
expectLib.extend(
|
|
21
|
+
expectLib.extend(filteredMatchers);
|
|
16
22
|
const expectWithSoft = expectLib;
|
|
17
23
|
Object.defineProperty(expectWithSoft, 'soft', {
|
|
18
24
|
value: (actual) => createSoftExpect(actual)
|
package/lib/matchers.js
CHANGED
|
@@ -1,62 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
...toBeElementsArrayOfSize,
|
|
33
|
-
...toBeClickable,
|
|
34
|
-
...toBeDisabled,
|
|
35
|
-
...toBeDisplayed,
|
|
36
|
-
...toBeDisplayedInViewport,
|
|
37
|
-
...toBeEnabled,
|
|
38
|
-
...toBeExisting,
|
|
39
|
-
...toBeFocused,
|
|
40
|
-
...toBeSelected,
|
|
41
|
-
...toHaveAttribute,
|
|
42
|
-
...toHaveChildren,
|
|
43
|
-
...toHaveClass,
|
|
44
|
-
...toHaveHref,
|
|
45
|
-
...toHaveHTML,
|
|
46
|
-
...toHaveId,
|
|
47
|
-
...toHaveSize,
|
|
48
|
-
...toHaveElementProperty,
|
|
49
|
-
...toHaveText,
|
|
50
|
-
...toHaveValue,
|
|
51
|
-
...toHaveStyle,
|
|
52
|
-
...toBeRequested,
|
|
53
|
-
...toBeRequestedTimes,
|
|
54
|
-
...toBeRequestedWith,
|
|
55
|
-
...snapshotMatchers
|
|
56
|
-
};
|
|
57
|
-
Object.keys(matchers).forEach((key) => {
|
|
58
|
-
if (key.endsWith('Fn')) {
|
|
59
|
-
delete matchers[key];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
export default matchers;
|
|
1
|
+
export * from './matchers/browser/toHaveClipboardText.js';
|
|
2
|
+
export * from './matchers/browser/toHaveTitle.js';
|
|
3
|
+
export * from './matchers/browser/toHaveUrl.js';
|
|
4
|
+
export * from './matchers/element/toBeClickable.js';
|
|
5
|
+
export * from './matchers/element/toBeDisabled.js';
|
|
6
|
+
export * from './matchers/element/toBeDisplayed.js';
|
|
7
|
+
export * from './matchers/element/toBeDisplayedInViewport.js';
|
|
8
|
+
export * from './matchers/element/toBeEnabled.js';
|
|
9
|
+
export * from './matchers/element/toBeExisting.js';
|
|
10
|
+
export * from './matchers/element/toBeFocused.js';
|
|
11
|
+
export * from './matchers/element/toBeSelected.js';
|
|
12
|
+
export * from './matchers/element/toHaveAttribute.js';
|
|
13
|
+
export * from './matchers/element/toHaveChildren.js';
|
|
14
|
+
export * from './matchers/element/toHaveClass.js';
|
|
15
|
+
export * from './matchers/element/toHaveComputedLabel.js';
|
|
16
|
+
export * from './matchers/element/toHaveComputedRole.js';
|
|
17
|
+
export * from './matchers/element/toHaveElementProperty.js';
|
|
18
|
+
export * from './matchers/element/toHaveHeight.js';
|
|
19
|
+
export * from './matchers/element/toHaveHref.js';
|
|
20
|
+
export * from './matchers/element/toHaveHTML.js';
|
|
21
|
+
export * from './matchers/element/toHaveId.js';
|
|
22
|
+
export * from './matchers/element/toHaveSize.js';
|
|
23
|
+
export * from './matchers/element/toHaveStyle.js';
|
|
24
|
+
export * from './matchers/element/toHaveText.js';
|
|
25
|
+
export * from './matchers/element/toHaveValue.js';
|
|
26
|
+
export * from './matchers/element/toHaveWidth.js';
|
|
27
|
+
export * from './matchers/elements/toBeElementsArrayOfSize.js';
|
|
28
|
+
export * from './matchers/mock/toBeRequested.js';
|
|
29
|
+
export * from './matchers/mock/toBeRequestedTimes.js';
|
|
30
|
+
export * from './matchers/mock/toBeRequestedWith.js';
|
|
31
|
+
export * from './matchers/snapshot.js';
|
package/lib/snapshot.js
CHANGED
|
@@ -63,17 +63,20 @@ export class SnapshotService {
|
|
|
63
63
|
async beforeTest(test) {
|
|
64
64
|
__classPrivateFieldSet(this, _SnapshotService_currentFilePath, test.file, "f");
|
|
65
65
|
__classPrivateFieldSet(this, _SnapshotService_currentTestName, `${test.parent} > ${test.title}`, "f");
|
|
66
|
-
await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").
|
|
66
|
+
await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").setup(test.file, __classPrivateFieldGet(this, _SnapshotService_options, "f"));
|
|
67
67
|
}
|
|
68
68
|
async beforeStep(step, scenario) {
|
|
69
69
|
const file = scenario.uri;
|
|
70
70
|
const testName = `${scenario.name} > ${step.text}`;
|
|
71
71
|
__classPrivateFieldSet(this, _SnapshotService_currentFilePath, file, "f");
|
|
72
72
|
__classPrivateFieldSet(this, _SnapshotService_currentTestName, testName, "f");
|
|
73
|
-
await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").
|
|
73
|
+
await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").setup(file, __classPrivateFieldGet(this, _SnapshotService_options, "f"));
|
|
74
74
|
}
|
|
75
75
|
async after() {
|
|
76
|
-
|
|
76
|
+
if (!__classPrivateFieldGet(this, _SnapshotService_currentFilePath, "f")) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const result = await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").finish(__classPrivateFieldGet(this, _SnapshotService_currentFilePath, "f"));
|
|
77
80
|
if (!result) {
|
|
78
81
|
return;
|
|
79
82
|
}
|
package/lib/softAssertService.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expect-webdriverio",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
|
|
5
5
|
"description": "WebdriverIO Assertion Library",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,29 +58,29 @@
|
|
|
58
58
|
"prepare": "husky install"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@vitest/snapshot": "^2.
|
|
61
|
+
"@vitest/snapshot": "^3.2.1",
|
|
62
62
|
"expect": "^29.7.0",
|
|
63
63
|
"jest-matcher-utils": "^29.7.0",
|
|
64
64
|
"lodash.isequal": "^4.5.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/debug": "^4.1.12",
|
|
68
|
-
"@types/jest": "^29.5.
|
|
68
|
+
"@types/jest": "^29.5.14",
|
|
69
69
|
"@types/lodash.isequal": "^4.5.8",
|
|
70
|
-
"@types/node": "^22.
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"@wdio/
|
|
74
|
-
"c8": "^10.1.
|
|
75
|
-
"eslint": "^9.
|
|
76
|
-
"husky": "^9.1.
|
|
77
|
-
"npm-run-all2": "^
|
|
78
|
-
"release-it": "^19.0.
|
|
70
|
+
"@types/node": "^22.15.29",
|
|
71
|
+
"@vitest/coverage-v8": "^3.2.1",
|
|
72
|
+
"@wdio/eslint": "^0.1.1",
|
|
73
|
+
"@wdio/types": "^9.15.0",
|
|
74
|
+
"c8": "^10.1.3",
|
|
75
|
+
"eslint": "^9.28.0",
|
|
76
|
+
"husky": "^9.1.7",
|
|
77
|
+
"npm-run-all2": "^8.0.4",
|
|
78
|
+
"release-it": "^19.0.3",
|
|
79
79
|
"rimraf": "^6.0.1",
|
|
80
|
-
"shelljs": "^0.
|
|
81
|
-
"typescript": "^5.
|
|
82
|
-
"vitest": "^3.
|
|
83
|
-
"webdriverio": "^9.
|
|
80
|
+
"shelljs": "^0.10.0",
|
|
81
|
+
"typescript": "^5.8.3",
|
|
82
|
+
"vitest": "^3.2.1",
|
|
83
|
+
"webdriverio": "^9.15.0"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@wdio/globals": "^9.0.0",
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
+
type ServiceInstance = import('@wdio/types').Services.ServiceInstance;
|
|
2
|
+
type Test = import('@wdio/types').Frameworks.Test;
|
|
3
|
+
type TestResult = import('@wdio/types').Frameworks.TestResult;
|
|
4
|
+
type PickleStep = import('@wdio/types').Frameworks.PickleStep;
|
|
5
|
+
type Scenario = import('@wdio/types').Frameworks.Scenario;
|
|
6
|
+
type SnapshotResult = import('@vitest/snapshot').SnapshotResult;
|
|
7
|
+
type SnapshotUpdateState = import('@vitest/snapshot').SnapshotUpdateState;
|
|
8
|
+
|
|
1
9
|
declare namespace ExpectWebdriverIO {
|
|
2
10
|
const expect: ExpectWebdriverIO.Expect
|
|
3
11
|
function setOptions(options: DefaultOptions): void
|
|
4
12
|
function getConfig(): any
|
|
5
13
|
|
|
6
14
|
interface SnapshotServiceArgs {
|
|
7
|
-
updateState?:
|
|
15
|
+
updateState?: SnapshotUpdateState
|
|
8
16
|
resolveSnapshotPath?: (path: string, extension: string) => string
|
|
9
17
|
}
|
|
10
18
|
|
|
11
19
|
class SnapshotService {
|
|
12
|
-
static initiate(options: SnapshotServiceArgs):
|
|
13
|
-
results:
|
|
20
|
+
static initiate(options: SnapshotServiceArgs): ServiceInstance & {
|
|
21
|
+
results: SnapshotResult[]
|
|
14
22
|
}
|
|
15
23
|
}
|
|
16
24
|
|
|
@@ -35,12 +43,12 @@ declare namespace ExpectWebdriverIO {
|
|
|
35
43
|
autoAssertOnTestEnd?: boolean;
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
class SoftAssertionService implements
|
|
46
|
+
class SoftAssertionService implements ServiceInstance {
|
|
39
47
|
constructor(serviceOptions?: SoftAssertionServiceOptions, capabilities?: any, config?: any);
|
|
40
|
-
beforeTest(test:
|
|
41
|
-
beforeStep(step:
|
|
42
|
-
afterTest(test:
|
|
43
|
-
afterStep(step:
|
|
48
|
+
beforeTest(test: Test): void;
|
|
49
|
+
beforeStep(step: PickleStep, scenario: Scenario): void;
|
|
50
|
+
afterTest(test: Test, context: any, result: TestResult): void;
|
|
51
|
+
afterStep(step: PickleStep, scenario: Scenario, result: { passed: boolean, error?: Error }): void;
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
interface AssertionResult {
|