expect-webdriverio 5.6.7 → 5.6.8
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/softExpect.js +22 -20
- package/package.json +24 -25
package/lib/softExpect.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { expect
|
|
1
|
+
import { expect } from './index.js';
|
|
2
2
|
import { SoftAssertService } from './softAssert.js';
|
|
3
|
+
const isPossibleMatcher = (propName) => propName.startsWith('to') && propName.length > 2;
|
|
3
4
|
const createSoftExpect = (actual) => {
|
|
4
5
|
const softService = SoftAssertService.getInstance();
|
|
5
6
|
return new Proxy({}, {
|
|
@@ -11,7 +12,7 @@ const createSoftExpect = (actual) => {
|
|
|
11
12
|
if (propName === 'resolves' || propName === 'rejects') {
|
|
12
13
|
return createSoftChainProxy(actual, propName, softService);
|
|
13
14
|
}
|
|
14
|
-
if (
|
|
15
|
+
if (isPossibleMatcher(propName)) {
|
|
15
16
|
return createSoftMatcher(actual, propName, softService);
|
|
16
17
|
}
|
|
17
18
|
return undefined;
|
|
@@ -20,28 +21,22 @@ const createSoftExpect = (actual) => {
|
|
|
20
21
|
};
|
|
21
22
|
const createSoftNotProxy = (actual, softService) => {
|
|
22
23
|
return new Proxy({}, {
|
|
23
|
-
get(
|
|
24
|
+
get(_target, prop) {
|
|
24
25
|
const propName = String(prop);
|
|
25
|
-
|
|
26
|
-
return createSoftMatcher(actual, propName, softService, 'not');
|
|
27
|
-
}
|
|
28
|
-
return undefined;
|
|
26
|
+
return isPossibleMatcher(propName) ? createSoftMatcher(actual, propName, softService, 'not') : undefined;
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
29
|
};
|
|
32
30
|
const createSoftChainProxy = (actual, chainType, softService) => {
|
|
33
31
|
return new Proxy({}, {
|
|
34
|
-
get(
|
|
32
|
+
get(_target, prop) {
|
|
35
33
|
const propName = String(prop);
|
|
36
|
-
|
|
37
|
-
return createSoftMatcher(actual, propName, softService, chainType);
|
|
38
|
-
}
|
|
39
|
-
return undefined;
|
|
34
|
+
return isPossibleMatcher(propName) ? createSoftMatcher(actual, propName, softService, chainType) : undefined;
|
|
40
35
|
}
|
|
41
36
|
});
|
|
42
37
|
};
|
|
43
38
|
const createSoftMatcher = (actual, matcherName, softService, prefix) => {
|
|
44
|
-
return
|
|
39
|
+
return (...args) => {
|
|
45
40
|
try {
|
|
46
41
|
let expectChain = expect(actual);
|
|
47
42
|
if (prefix === 'not') {
|
|
@@ -53,16 +48,23 @@ const createSoftMatcher = (actual, matcherName, softService, prefix) => {
|
|
|
53
48
|
else if (prefix === 'rejects') {
|
|
54
49
|
expectChain = expectChain.rejects;
|
|
55
50
|
}
|
|
56
|
-
|
|
51
|
+
const assertionResult = expectChain[matcherName](...args);
|
|
52
|
+
if (assertionResult instanceof Promise) {
|
|
53
|
+
return assertionResult.catch((error) => handlingMatcherFailure(prefix, matcherName, softService, error));
|
|
54
|
+
}
|
|
55
|
+
return assertionResult;
|
|
57
56
|
}
|
|
58
57
|
catch (error) {
|
|
59
|
-
|
|
60
|
-
softService.addFailure(error, fullMatcherName);
|
|
61
|
-
return {
|
|
62
|
-
pass: true,
|
|
63
|
-
message: () => `Soft assertion failed: ${fullMatcherName}`
|
|
64
|
-
};
|
|
58
|
+
return handlingMatcherFailure(prefix, matcherName, softService, error);
|
|
65
59
|
}
|
|
66
60
|
};
|
|
67
61
|
};
|
|
62
|
+
function handlingMatcherFailure(prefix, matcherName, softService, error) {
|
|
63
|
+
const fullMatcherName = prefix ? `${prefix}.${matcherName}` : matcherName;
|
|
64
|
+
softService.addFailure(error, fullMatcherName);
|
|
65
|
+
return {
|
|
66
|
+
pass: true,
|
|
67
|
+
message: () => `Soft assertion failed: ${fullMatcherName}`
|
|
68
|
+
};
|
|
69
|
+
}
|
|
68
70
|
export default createSoftExpect;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expect-webdriverio",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.8",
|
|
4
4
|
"author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
|
|
5
5
|
"description": "WebdriverIO Assertion Library",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,43 +65,42 @@
|
|
|
65
65
|
"test:unit": "vitest --run",
|
|
66
66
|
"test:types": "npm run ts && npm run tsc:root-types",
|
|
67
67
|
"ts": "run-s ts:* ts:*:*",
|
|
68
|
-
"ts:
|
|
69
|
-
"ts:
|
|
70
|
-
"ts:
|
|
71
|
-
"ts:
|
|
72
|
-
"ts:jasmine-async": "cd test-types/jasmine-async && tsc --project ./tsconfig.json",
|
|
68
|
+
"ts:jasmine": "cd test-types/jasmine && vitest --typecheck --typecheck.tsconfig ./tsconfig.json --run",
|
|
69
|
+
"ts:jasmine-global-expect-async": "cd test-types/jasmine-global-expect-async && vitest --typecheck --typecheck.tsconfig ./tsconfig.json --run",
|
|
70
|
+
"ts:jest:@types-jest": "cd test-types/jest-@types_jest && vitest --typecheck --typecheck.tsconfig ./tsconfig.json --run",
|
|
71
|
+
"ts:mocha": "cd test-types/mocha && vitest --typecheck --typecheck.tsconfig ./tsconfig.json --run",
|
|
73
72
|
"checks:all": "npm run build && npm run compile && npm run tsc:root-types && npm run test && npm run ts",
|
|
74
73
|
"watch": "npm run compile -- --watch",
|
|
75
74
|
"prepare": "husky install",
|
|
76
|
-
"playgrounds:setup": "
|
|
77
|
-
"playgrounds:checks:all": "
|
|
78
|
-
"playgrounds:snapshots:update": "cd playgrounds
|
|
75
|
+
"playgrounds:setup": "cd playgrounds && npm run setup",
|
|
76
|
+
"playgrounds:checks:all": "cd playgrounds && npm run checks:all",
|
|
77
|
+
"playgrounds:snapshots:update": "cd playgrounds && npm run snapshots:update"
|
|
79
78
|
},
|
|
80
79
|
"dependencies": {
|
|
81
|
-
"@vitest/snapshot": "^4.
|
|
80
|
+
"@vitest/snapshot": "^4.1.7",
|
|
82
81
|
"deep-eql": "^5.0.2",
|
|
83
|
-
"expect": "^30.
|
|
84
|
-
"jest-matcher-utils": "^30.
|
|
82
|
+
"expect": "^30.4.1",
|
|
83
|
+
"jest-matcher-utils": "^30.4.1"
|
|
85
84
|
},
|
|
86
85
|
"devDependencies": {
|
|
87
|
-
"@types/debug": "^4.1.
|
|
88
|
-
"@types/jasmine": "^5.1.
|
|
86
|
+
"@types/debug": "^4.1.13",
|
|
87
|
+
"@types/jasmine": "^5.1.15",
|
|
89
88
|
"@types/jest": "^30.0.0",
|
|
90
|
-
"@types/node": "^24.
|
|
89
|
+
"@types/node": "^24.12.4",
|
|
91
90
|
"@types/mocha": "^10.0.10",
|
|
92
|
-
"@jest/globals": "^30.
|
|
93
|
-
"@vitest/coverage-v8": "^4.
|
|
94
|
-
"@wdio/eslint": "^0.1.
|
|
95
|
-
"@wdio/types": "^9.
|
|
96
|
-
"eslint": "^9.39.
|
|
91
|
+
"@jest/globals": "^30.4.1",
|
|
92
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
93
|
+
"@wdio/eslint": "^0.1.3",
|
|
94
|
+
"@wdio/types": "^9.27.2",
|
|
95
|
+
"eslint": "^9.39.4",
|
|
97
96
|
"husky": "^9.1.7",
|
|
98
|
-
"npm-run-all2": "^
|
|
99
|
-
"release-it": "^20.0
|
|
100
|
-
"rimraf": "^6.1.
|
|
97
|
+
"npm-run-all2": "^9.0.1",
|
|
98
|
+
"release-it": "^20.2.0",
|
|
99
|
+
"rimraf": "^6.1.3",
|
|
101
100
|
"shelljs": "^0.10.0",
|
|
102
101
|
"typescript": "^5.9.3",
|
|
103
|
-
"vitest": "^4.
|
|
104
|
-
"webdriverio": "^9.
|
|
102
|
+
"vitest": "^4.1.7",
|
|
103
|
+
"webdriverio": "^9.27.2"
|
|
105
104
|
},
|
|
106
105
|
"peerDependencies": {
|
|
107
106
|
"@wdio/globals": "^9.0.0",
|