expect-webdriverio 5.4.3 → 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 =
|
|
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?.({
|
|
@@ -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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
82
|
+
if (expected === undefined ||
|
|
83
83
|
typeof expected === 'object' && Object.keys(expected).length === 0) {
|
|
84
84
|
return true;
|
|
85
85
|
}
|
|
@@ -98,7 +98,7 @@ const isMatcher = (filter) => {
|
|
|
98
98
|
typeof proto.asymmetricMatch === 'function');
|
|
99
99
|
};
|
|
100
100
|
const minifyRequestMock = (requestMock, requestedWith) => {
|
|
101
|
-
if (
|
|
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 (
|
|
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 (
|
|
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.
|
|
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;
|
|
@@ -217,12 +215,12 @@ export const compareObject = (actual, expected) => {
|
|
|
217
215
|
result: deepEql(actual, expected),
|
|
218
216
|
};
|
|
219
217
|
};
|
|
220
|
-
export const compareStyle = async (actualEl, style, { ignoreCase =
|
|
218
|
+
export const compareStyle = async (actualEl, style, { ignoreCase = false, trim = true, containing = false, atStart = false, atEnd = false, atIndex, replace, }) => {
|
|
221
219
|
let result = true;
|
|
222
220
|
const actual = {};
|
|
223
221
|
for (const key in style) {
|
|
224
222
|
const css = await actualEl.getCSSProperty(key);
|
|
225
|
-
let actualVal = css.value;
|
|
223
|
+
let actualVal = String(css.value || '');
|
|
226
224
|
let expectedVal = style[key];
|
|
227
225
|
if (trim) {
|
|
228
226
|
actualVal = actualVal.trim();
|
|
@@ -232,8 +230,31 @@ export const compareStyle = async (actualEl, style, { ignoreCase = true, trim =
|
|
|
232
230
|
actualVal = actualVal.toLowerCase();
|
|
233
231
|
expectedVal = expectedVal.toLowerCase();
|
|
234
232
|
}
|
|
235
|
-
|
|
236
|
-
|
|
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
|
+
}
|
|
237
258
|
}
|
|
238
259
|
return {
|
|
239
260
|
value: actual,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expect-webdriverio",
|
|
3
|
-
"version": "5.
|
|
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,27 +60,27 @@
|
|
|
60
60
|
"prepare": "husky install"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@vitest/snapshot": "^
|
|
63
|
+
"@vitest/snapshot": "^4.0.12",
|
|
64
64
|
"deep-eql": "^5.0.2",
|
|
65
|
-
"expect": "^30.
|
|
66
|
-
"jest-matcher-utils": "^30.
|
|
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.
|
|
72
|
-
"@vitest/coverage-v8": "^
|
|
73
|
-
"@wdio/eslint": "^0.1.
|
|
74
|
-
"@wdio/types": "^9.
|
|
75
|
-
"eslint": "^9.
|
|
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",
|
|
76
76
|
"husky": "^9.1.7",
|
|
77
77
|
"npm-run-all2": "^8.0.4",
|
|
78
|
-
"release-it": "^19.0.
|
|
79
|
-
"rimraf": "^6.
|
|
78
|
+
"release-it": "^19.0.6",
|
|
79
|
+
"rimraf": "^6.1.2",
|
|
80
80
|
"shelljs": "^0.10.0",
|
|
81
|
-
"typescript": "^5.
|
|
82
|
-
"vitest": "^
|
|
83
|
-
"webdriverio": "^9.
|
|
81
|
+
"typescript": "^5.9.3",
|
|
82
|
+
"vitest": "^4.0.12",
|
|
83
|
+
"webdriverio": "^9.20.1"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@wdio/globals": "^9.0.0",
|