expect-webdriverio 5.4.2 → 5.5.0

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.
@@ -53,7 +53,7 @@ export async function toHaveAttribute(received, attribute, value, options = DEFA
53
53
  expectedValue: [attribute, value],
54
54
  options,
55
55
  });
56
- const result = typeof value !== 'undefined'
56
+ const result = value !== undefined
57
57
  ? await toHaveAttributeAndValue.call(this, received, attribute, value, options)
58
58
  : await toHaveAttributeFn.call(this, received, attribute);
59
59
  await options.afterAssertion?.({
@@ -13,7 +13,7 @@ async function condition(el, text, options) {
13
13
  : compareText(actualText, text, options).result;
14
14
  resultArray.push(result);
15
15
  }
16
- checkAllValuesMatchCondition = resultArray.every(result => result);
16
+ checkAllValuesMatchCondition = resultArray.every(Boolean);
17
17
  }
18
18
  else {
19
19
  const actualText = await el.getText();
@@ -45,7 +45,7 @@ export async function toBeRequestedWith(received, expectedValue = {}, options =
45
45
  return result;
46
46
  }
47
47
  const methodMatcher = (method, expected) => {
48
- if (typeof expected === 'undefined') {
48
+ if (expected === undefined) {
49
49
  return true;
50
50
  }
51
51
  if (!Array.isArray(expected)) {
@@ -61,7 +61,7 @@ const methodMatcher = (method, expected) => {
61
61
  .includes(method);
62
62
  };
63
63
  const statusCodeMatcher = (statusCode, expected) => {
64
- if (typeof expected === 'undefined') {
64
+ if (expected === undefined) {
65
65
  return true;
66
66
  }
67
67
  if (!Array.isArray(expected)) {
@@ -70,7 +70,7 @@ const statusCodeMatcher = (statusCode, expected) => {
70
70
  return expected.includes(statusCode);
71
71
  };
72
72
  const urlMatcher = (url, expected) => {
73
- if (typeof expected === 'undefined') {
73
+ if (expected === undefined) {
74
74
  return true;
75
75
  }
76
76
  if (typeof expected === 'function') {
@@ -79,7 +79,7 @@ const urlMatcher = (url, expected) => {
79
79
  return equals(url, expected);
80
80
  };
81
81
  const headersMatcher = (headers, expected) => {
82
- if (typeof expected === 'undefined' ||
82
+ if (expected === undefined ||
83
83
  typeof expected === 'object' && Object.keys(expected).length === 0) {
84
84
  return true;
85
85
  }
@@ -89,16 +89,16 @@ const headersMatcher = (headers, expected) => {
89
89
  return equals(headers, expected);
90
90
  };
91
91
  const isMatcher = (filter) => {
92
+ const proto = Object.getPrototypeOf(filter);
92
93
  return (typeof filter === 'object' &&
93
94
  filter !== null &&
94
- '__proto__' in filter &&
95
- typeof filter.__proto__ === 'object' &&
96
- filter.__proto__ &&
97
- 'asymmetricMatch' in filter.__proto__ &&
98
- typeof filter.__proto__.asymmetricMatch === 'function');
95
+ typeof proto === 'object' &&
96
+ proto &&
97
+ 'asymmetricMatch' in proto &&
98
+ typeof proto.asymmetricMatch === 'function');
99
99
  };
100
100
  const minifyRequestMock = (requestMock, requestedWith) => {
101
- if (typeof requestMock === 'undefined') {
101
+ if (requestMock === undefined) {
102
102
  return requestMock;
103
103
  }
104
104
  const r = {
@@ -123,7 +123,7 @@ const minifyRequestedWith = (r) => {
123
123
  return result;
124
124
  };
125
125
  const requestedWithParamToString = (param, transformFn) => {
126
- if (typeof param === 'undefined') {
126
+ if (param === undefined) {
127
127
  return;
128
128
  }
129
129
  if (typeof param === 'function') {
@@ -175,7 +175,7 @@ const shortenString = (str, limit = STR_LIMIT) => {
175
175
  };
176
176
  const deleteUndefinedValues = (obj, baseline = obj) => {
177
177
  Object.keys(obj).forEach((k) => {
178
- if (typeof baseline[k] === 'undefined') {
178
+ if (baseline[k] === undefined) {
179
179
  delete obj[k];
180
180
  }
181
181
  });
@@ -1 +1 @@
1
- {"root":["../src/constants.ts","../src/index.ts","../src/jasmineUtils.ts","../src/matchers.ts","../src/snapshot.ts","../src/softAssert.ts","../src/softAssertService.ts","../src/softExpect.ts","../src/types.ts","../src/utils.ts","../src/matchers/snapshot.ts","../src/matchers/browser/toHaveClipboardText.ts","../src/matchers/browser/toHaveTitle.ts","../src/matchers/browser/toHaveUrl.ts","../src/matchers/element/toBeClickable.ts","../src/matchers/element/toBeDisabled.ts","../src/matchers/element/toBeDisplayed.ts","../src/matchers/element/toBeDisplayedInViewport.ts","../src/matchers/element/toBeEnabled.ts","../src/matchers/element/toBeExisting.ts","../src/matchers/element/toBeFocused.ts","../src/matchers/element/toBeSelected.ts","../src/matchers/element/toHaveAttribute.ts","../src/matchers/element/toHaveChildren.ts","../src/matchers/element/toHaveClass.ts","../src/matchers/element/toHaveComputedLabel.ts","../src/matchers/element/toHaveComputedRole.ts","../src/matchers/element/toHaveElementProperty.ts","../src/matchers/element/toHaveHTML.ts","../src/matchers/element/toHaveHeight.ts","../src/matchers/element/toHaveHref.ts","../src/matchers/element/toHaveId.ts","../src/matchers/element/toHaveSize.ts","../src/matchers/element/toHaveStyle.ts","../src/matchers/element/toHaveText.ts","../src/matchers/element/toHaveValue.ts","../src/matchers/element/toHaveWidth.ts","../src/matchers/elements/toBeElementsArrayOfSize.ts","../src/matchers/mock/toBeRequested.ts","../src/matchers/mock/toBeRequestedTimes.ts","../src/matchers/mock/toBeRequestedWith.ts","../src/util/elementsUtil.ts","../src/util/executeCommand.ts","../src/util/formatMessage.ts","../src/util/refetchElements.ts"],"version":"5.8.3"}
1
+ {"root":["../src/constants.ts","../src/index.ts","../src/jasmineUtils.ts","../src/matchers.ts","../src/snapshot.ts","../src/softAssert.ts","../src/softAssertService.ts","../src/softExpect.ts","../src/types.ts","../src/utils.ts","../src/matchers/snapshot.ts","../src/matchers/browser/toHaveClipboardText.ts","../src/matchers/browser/toHaveTitle.ts","../src/matchers/browser/toHaveUrl.ts","../src/matchers/element/toBeClickable.ts","../src/matchers/element/toBeDisabled.ts","../src/matchers/element/toBeDisplayed.ts","../src/matchers/element/toBeDisplayedInViewport.ts","../src/matchers/element/toBeEnabled.ts","../src/matchers/element/toBeExisting.ts","../src/matchers/element/toBeFocused.ts","../src/matchers/element/toBeSelected.ts","../src/matchers/element/toHaveAttribute.ts","../src/matchers/element/toHaveChildren.ts","../src/matchers/element/toHaveClass.ts","../src/matchers/element/toHaveComputedLabel.ts","../src/matchers/element/toHaveComputedRole.ts","../src/matchers/element/toHaveElementProperty.ts","../src/matchers/element/toHaveHTML.ts","../src/matchers/element/toHaveHeight.ts","../src/matchers/element/toHaveHref.ts","../src/matchers/element/toHaveId.ts","../src/matchers/element/toHaveSize.ts","../src/matchers/element/toHaveStyle.ts","../src/matchers/element/toHaveText.ts","../src/matchers/element/toHaveValue.ts","../src/matchers/element/toHaveWidth.ts","../src/matchers/elements/toBeElementsArrayOfSize.ts","../src/matchers/mock/toBeRequested.ts","../src/matchers/mock/toBeRequestedTimes.ts","../src/matchers/mock/toBeRequestedWith.ts","../src/util/elementsUtil.ts","../src/util/executeCommand.ts","../src/util/formatMessage.ts","../src/util/refetchElements.ts"],"version":"5.9.3"}
package/lib/utils.js CHANGED
@@ -10,7 +10,6 @@ const asymmetricMatcher = typeof Symbol === 'function' && Symbol.for
10
10
  : 1267621;
11
11
  export function isAsymmeyricMatcher(expected) {
12
12
  return (typeof expected === 'object' &&
13
- typeof expected === 'object' &&
14
13
  expected &&
15
14
  '$$typeof' in expected &&
16
15
  'asymmetricMatch' in expected &&
@@ -31,7 +30,6 @@ const waitUntil = async (condition, isNot = false, { wait = DEFAULT_OPTIONS.wait
31
30
  if (Date.now() - start > wait) {
32
31
  throw new Error('timeout');
33
32
  }
34
- error = undefined;
35
33
  try {
36
34
  const result = isNot !== (await condition());
37
35
  error = undefined;
@@ -117,7 +115,6 @@ export const compareText = (actual, expected, { ignoreCase = false, trim = true,
117
115
  result
118
116
  };
119
117
  }
120
- expected = expected;
121
118
  if (expected instanceof RegExp) {
122
119
  return {
123
120
  value: actual,
@@ -218,12 +215,12 @@ export const compareObject = (actual, expected) => {
218
215
  result: deepEql(actual, expected),
219
216
  };
220
217
  };
221
- export const compareStyle = async (actualEl, style, { ignoreCase = true, trim = false }) => {
218
+ export const compareStyle = async (actualEl, style, { ignoreCase = false, trim = true, containing = false, atStart = false, atEnd = false, atIndex, replace, }) => {
222
219
  let result = true;
223
220
  const actual = {};
224
221
  for (const key in style) {
225
222
  const css = await actualEl.getCSSProperty(key);
226
- let actualVal = css.value;
223
+ let actualVal = String(css.value || '');
227
224
  let expectedVal = style[key];
228
225
  if (trim) {
229
226
  actualVal = actualVal.trim();
@@ -233,8 +230,31 @@ export const compareStyle = async (actualEl, style, { ignoreCase = true, trim =
233
230
  actualVal = actualVal.toLowerCase();
234
231
  expectedVal = expectedVal.toLowerCase();
235
232
  }
236
- result = result && actualVal === expectedVal;
237
- actual[key] = css.value;
233
+ if (containing) {
234
+ result = actualVal.includes(expectedVal);
235
+ actual[key] = actualVal;
236
+ }
237
+ else if (atStart) {
238
+ result = actualVal.startsWith(expectedVal);
239
+ actual[key] = actualVal;
240
+ }
241
+ else if (atEnd) {
242
+ result = actualVal.endsWith(expectedVal);
243
+ actual[key] = actualVal;
244
+ }
245
+ else if (atIndex) {
246
+ result = actualVal.substring(atIndex, actualVal.length).startsWith(expectedVal);
247
+ actual[key] = actualVal;
248
+ }
249
+ else if (replace) {
250
+ const replacedActual = replaceActual(replace, actualVal);
251
+ result = replacedActual === expectedVal;
252
+ actual[key] = replacedActual;
253
+ }
254
+ else {
255
+ result = result && actualVal === expectedVal;
256
+ actual[key] = css.value;
257
+ }
238
258
  }
239
259
  return {
240
260
  value: actual,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expect-webdriverio",
3
- "version": "5.4.2",
3
+ "version": "5.5.0",
4
4
  "author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
5
5
  "description": "WebdriverIO Assertion Library",
6
6
  "license": "MIT",
@@ -60,28 +60,27 @@
60
60
  "prepare": "husky install"
61
61
  },
62
62
  "dependencies": {
63
- "@vitest/snapshot": "^3.2.4",
63
+ "@vitest/snapshot": "^4.0.12",
64
64
  "deep-eql": "^5.0.2",
65
- "expect": "^30.0.0",
66
- "jest-matcher-utils": "^30.0.0"
65
+ "expect": "^30.2.0",
66
+ "jest-matcher-utils": "^30.2.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/debug": "^4.1.12",
70
70
  "@types/jest": "^30.0.0",
71
- "@types/node": "^24.0.3",
72
- "@vitest/coverage-v8": "^3.2.4",
73
- "@wdio/eslint": "^0.1.1",
74
- "@wdio/types": "^9.15.0",
75
- "c8": "^10.1.3",
76
- "eslint": "^9.29.0",
71
+ "@types/node": "^24.10.1",
72
+ "@vitest/coverage-v8": "^4.0.12",
73
+ "@wdio/eslint": "^0.1.2",
74
+ "@wdio/types": "^9.20.0",
75
+ "eslint": "^9.39.1",
77
76
  "husky": "^9.1.7",
78
77
  "npm-run-all2": "^8.0.4",
79
- "release-it": "^19.0.3",
80
- "rimraf": "^6.0.1",
78
+ "release-it": "^19.0.6",
79
+ "rimraf": "^6.1.2",
81
80
  "shelljs": "^0.10.0",
82
- "typescript": "^5.8.3",
83
- "vitest": "^3.2.4",
84
- "webdriverio": "^9.15.0"
81
+ "typescript": "^5.9.3",
82
+ "vitest": "^4.0.12",
83
+ "webdriverio": "^9.20.1"
85
84
  },
86
85
  "peerDependencies": {
87
86
  "@wdio/globals": "^9.0.0",