expect-webdriverio 4.15.1 → 4.15.3

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/utils.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import isEqual from 'lodash.isequal';
2
+ import expect from 'expect';
2
3
  import { DEFAULT_OPTIONS } from './constants.js';
3
4
  import { wrapExpectedWithArray } from './util/elementsUtil.js';
4
5
  import { executeCommand } from './util/executeCommand.js';
@@ -10,6 +11,9 @@ const asymmetricMatcher = typeof Symbol === 'function' && Symbol.for
10
11
  export function isAsymmeyricMatcher(expected) {
11
12
  return typeof expected === 'object' && '$$typeof' in expected && expected.$$typeof === asymmetricMatcher && expected.asymmetricMatch;
12
13
  }
14
+ function isStringContainingMatcher(expected) {
15
+ return isAsymmeyricMatcher(expected) && ['StringContaining', 'StringNotContaining'].includes(expected.toString());
16
+ }
13
17
  const waitUntil = async (condition, isNot = false, { wait = DEFAULT_OPTIONS.wait, interval = DEFAULT_OPTIONS.interval } = {}) => {
14
18
  if (wait === 0) {
15
19
  return await condition();
@@ -95,6 +99,11 @@ export const compareText = (actual, expected, { ignoreCase = false, trim = true,
95
99
  if (typeof expected === 'string') {
96
100
  expected = expected.toLowerCase();
97
101
  }
102
+ else if (isStringContainingMatcher(expected)) {
103
+ expected = (expected.toString() === 'StringContaining'
104
+ ? expect.stringContaining(expected.sample?.toString().toLowerCase())
105
+ : expect.not.stringContaining(expected.sample?.toString().toLowerCase()));
106
+ }
98
107
  }
99
108
  if (isAsymmeyricMatcher(expected)) {
100
109
  const result = expected.asymmetricMatch(actual);
@@ -154,12 +163,25 @@ export const compareTextWithArray = (actual, expectedArray, { ignoreCase = false
154
163
  }
155
164
  if (ignoreCase) {
156
165
  actual = actual.toLowerCase();
157
- expectedArray = expectedArray.map((item) => (item instanceof RegExp ? item : item.toLowerCase()));
166
+ expectedArray = expectedArray.map((item) => {
167
+ if (typeof item === 'string') {
168
+ return item.toLowerCase();
169
+ }
170
+ if (isStringContainingMatcher(item)) {
171
+ return (item.toString() === 'StringContaining'
172
+ ? expect.stringContaining(item.sample?.toString().toLowerCase())
173
+ : expect.not.stringContaining(item.sample?.toString().toLowerCase()));
174
+ }
175
+ return item;
176
+ });
158
177
  }
159
178
  const textInArray = expectedArray.some((expected) => {
160
179
  if (expected instanceof RegExp) {
161
180
  return !!actual.match(expected);
162
181
  }
182
+ if (isAsymmeyricMatcher(expected)) {
183
+ return expected.asymmetricMatch(actual);
184
+ }
163
185
  if (containing) {
164
186
  return actual.includes(expected);
165
187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expect-webdriverio",
3
- "version": "4.15.1",
3
+ "version": "4.15.3",
4
4
  "author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
5
5
  "description": "WebdriverIO Assertion Library",
6
6
  "license": "MIT",
@@ -61,14 +61,14 @@
61
61
  "@types/debug": "^4.1.12",
62
62
  "@types/jest": "^29.5.11",
63
63
  "@types/lodash.isequal": "^4.5.8",
64
- "@types/node": "^20.11.14",
64
+ "@types/node": "^22.0.0",
65
65
  "@typescript-eslint/eslint-plugin": "^7.0.0",
66
66
  "@typescript-eslint/parser": "^7.0.1",
67
67
  "@vitest/coverage-v8": "^1.2.2",
68
- "c8": "^9.1.0",
68
+ "c8": "^10.1.2",
69
69
  "eslint": "^8.56.0",
70
70
  "eslint-plugin-import": "^2.29.1",
71
- "eslint-plugin-unicorn": "^53.0.0",
71
+ "eslint-plugin-unicorn": "^55.0.0",
72
72
  "husky": "^9.0.7",
73
73
  "npm-run-all2": "^6.1.2",
74
74
  "release-it": "^17.0.3",
@@ -76,7 +76,7 @@
76
76
  "shelljs": "^0.8.5",
77
77
  "typescript": "^5.3.3",
78
78
  "vitest": "1.6.0",
79
- "webdriverio": "8.38.2"
79
+ "webdriverio": "8.40.2"
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@wdio/globals": "^8.29.3",
@@ -84,7 +84,7 @@
84
84
  "webdriverio": "^8.29.3"
85
85
  },
86
86
  "dependencies": {
87
- "@vitest/snapshot": "^1.2.2",
87
+ "@vitest/snapshot": "^2.0.3",
88
88
  "expect": "^29.7.0",
89
89
  "jest-matcher-utils": "^29.7.0",
90
90
  "lodash.isequal": "^4.5.0"
@@ -560,6 +560,7 @@ declare namespace ExpectWebdriverIO {
560
560
  sample?: any
561
561
  $$typeof: symbol
562
562
  asymmetricMatch(...args: any[]): boolean
563
+ toString(): string
563
564
  }
564
565
  }
565
566