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.
Files changed (2) hide show
  1. package/lib/softExpect.js +22 -20
  2. package/package.json +24 -25
package/lib/softExpect.js CHANGED
@@ -1,5 +1,6 @@
1
- import { expect, matchers } from './index.js';
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 (matchers.has(propName)) {
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(target, prop) {
24
+ get(_target, prop) {
24
25
  const propName = String(prop);
25
- if (matchers.has(propName)) {
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(target, prop) {
32
+ get(_target, prop) {
35
33
  const propName = String(prop);
36
- if (matchers.has(propName)) {
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 async (...args) => {
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
- return await expectChain[matcherName](...args);
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
- const fullMatcherName = prefix ? `${prefix}.${matcherName}` : matcherName;
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.7",
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:jest:@jest/global": "cd test-types/jest-@jest_global && tsc --project ./tsconfig.json",
69
- "ts:jest:@types-jest": "cd test-types/jest-@types_jest && tsc --project ./tsconfig.json",
70
- "ts:mocha": "cd test-types/mocha && tsc --project ./tsconfig.json",
71
- "ts:jasmine": "cd test-types/jasmine && tsc --project ./tsconfig.json",
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": "for dir in playgrounds/*/; do cd \"$dir\" && npm install && cd ../..; done",
77
- "playgrounds:checks:all": "for dir in playgrounds/*/; do cd \"$dir\" && npm run checks:all && cd ../..; done",
78
- "playgrounds:snapshots:update": "cd playgrounds/mocha && npm run snapshots:update && cd ../jest && npm run snapshots:update && cd ../.."
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.0.16",
80
+ "@vitest/snapshot": "^4.1.7",
82
81
  "deep-eql": "^5.0.2",
83
- "expect": "^30.2.0",
84
- "jest-matcher-utils": "^30.2.0"
82
+ "expect": "^30.4.1",
83
+ "jest-matcher-utils": "^30.4.1"
85
84
  },
86
85
  "devDependencies": {
87
- "@types/debug": "^4.1.12",
88
- "@types/jasmine": "^5.1.8",
86
+ "@types/debug": "^4.1.13",
87
+ "@types/jasmine": "^5.1.15",
89
88
  "@types/jest": "^30.0.0",
90
- "@types/node": "^24.10.1",
89
+ "@types/node": "^24.12.4",
91
90
  "@types/mocha": "^10.0.10",
92
- "@jest/globals": "^30.2.0",
93
- "@vitest/coverage-v8": "^4.0.16",
94
- "@wdio/eslint": "^0.1.2",
95
- "@wdio/types": "^9.20.0",
96
- "eslint": "^9.39.2",
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": "^8.0.4",
99
- "release-it": "^20.0.1",
100
- "rimraf": "^6.1.2",
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.0.16",
104
- "webdriverio": "^9.21.0"
102
+ "vitest": "^4.1.7",
103
+ "webdriverio": "^9.27.2"
105
104
  },
106
105
  "peerDependencies": {
107
106
  "@wdio/globals": "^9.0.0",