expect-webdriverio 4.3.0 → 4.4.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.
- package/lib/matchers/element/toHaveComputedLabel.js +26 -0
- package/lib/matchers/element/toHaveComputedLabelContaining.js +7 -0
- package/lib/matchers/element/toHaveComputedRole.js +26 -0
- package/lib/matchers/element/toHaveComputedRoleContaining.js +7 -0
- package/lib/matchers/element/toHaveHTML.js +26 -0
- package/lib/matchers/element/toHaveHTMLContaining.js +7 -0
- package/lib/matchers/element/toHaveHeight.js +26 -0
- package/lib/matchers/element/toHaveSize.js +23 -0
- package/lib/matchers/element/toHaveWidth.js +26 -0
- package/lib/utils.js +13 -0
- package/package.json +4 -2
- package/types/expect-webdriverio.d.ts +464 -375
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray, updateElementsArray, } from '../../utils.js';
|
|
2
|
+
async function condition(el, label, options) {
|
|
3
|
+
const actualLabel = await el.getComputedLabel();
|
|
4
|
+
if (Array.isArray(label)) {
|
|
5
|
+
return compareTextWithArray(actualLabel, label, options);
|
|
6
|
+
}
|
|
7
|
+
return compareText(actualLabel, label, options);
|
|
8
|
+
}
|
|
9
|
+
export async function toHaveComputedLabel(received, label, options = {}) {
|
|
10
|
+
const isNot = this.isNot;
|
|
11
|
+
const { expectation = 'computed label', verb = 'have' } = this;
|
|
12
|
+
let el = await received;
|
|
13
|
+
let actualLabel;
|
|
14
|
+
const pass = await waitUntil(async () => {
|
|
15
|
+
const result = await executeCommand.call(this, el, condition, options, [label, options]);
|
|
16
|
+
el = result.el;
|
|
17
|
+
actualLabel = result.values;
|
|
18
|
+
return result.success;
|
|
19
|
+
}, isNot, options);
|
|
20
|
+
updateElementsArray(pass, received, el);
|
|
21
|
+
const message = enhanceError(el, wrapExpectedWithArray(el, actualLabel, label), actualLabel, this, verb, expectation, '', options);
|
|
22
|
+
return {
|
|
23
|
+
pass,
|
|
24
|
+
message: () => message,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray, updateElementsArray, } from '../../utils.js';
|
|
2
|
+
async function condition(el, role, options) {
|
|
3
|
+
const actualRole = await el.getComputedRole();
|
|
4
|
+
if (Array.isArray(role)) {
|
|
5
|
+
return compareTextWithArray(actualRole, role, options);
|
|
6
|
+
}
|
|
7
|
+
return compareText(actualRole, role, options);
|
|
8
|
+
}
|
|
9
|
+
export async function toHaveComputedRole(received, role, options = {}) {
|
|
10
|
+
const isNot = this.isNot;
|
|
11
|
+
const { expectation = 'computed role', verb = 'have' } = this;
|
|
12
|
+
let el = await received;
|
|
13
|
+
let actualRole;
|
|
14
|
+
const pass = await waitUntil(async () => {
|
|
15
|
+
const result = await executeCommand.call(this, el, condition, options, [role, options]);
|
|
16
|
+
el = result.el;
|
|
17
|
+
actualRole = result.values;
|
|
18
|
+
return result.success;
|
|
19
|
+
}, isNot, options);
|
|
20
|
+
updateElementsArray(pass, received, el);
|
|
21
|
+
const message = enhanceError(el, wrapExpectedWithArray(el, actualRole, role), actualRole, this, verb, expectation, '', options);
|
|
22
|
+
return {
|
|
23
|
+
pass,
|
|
24
|
+
message: () => message,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray, updateElementsArray } from '../../utils.js';
|
|
2
|
+
async function condition(el, html, options) {
|
|
3
|
+
const actualHTML = await el.getHTML(options.includeSelectorTag);
|
|
4
|
+
if (Array.isArray(html)) {
|
|
5
|
+
return compareTextWithArray(actualHTML, html, options);
|
|
6
|
+
}
|
|
7
|
+
return compareText(actualHTML, html, options);
|
|
8
|
+
}
|
|
9
|
+
export async function toHaveHTML(received, html, options = {}) {
|
|
10
|
+
const isNot = this.isNot;
|
|
11
|
+
const { expectation = 'HTML', verb = 'have' } = this;
|
|
12
|
+
let el = await received;
|
|
13
|
+
let actualHTML;
|
|
14
|
+
const pass = await waitUntil(async () => {
|
|
15
|
+
const result = await executeCommand.call(this, el, condition, options, [html, options]);
|
|
16
|
+
el = result.el;
|
|
17
|
+
actualHTML = result.values;
|
|
18
|
+
return result.success;
|
|
19
|
+
}, isNot, options);
|
|
20
|
+
updateElementsArray(pass, received, el);
|
|
21
|
+
const message = enhanceError(el, wrapExpectedWithArray(el, actualHTML, html), actualHTML, this, verb, expectation, '', options);
|
|
22
|
+
return {
|
|
23
|
+
pass,
|
|
24
|
+
message: () => message
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, updateElementsArray, } from '../../utils.js';
|
|
2
|
+
async function condition(el, height) {
|
|
3
|
+
const actualHeight = await el.getSize('height');
|
|
4
|
+
return {
|
|
5
|
+
value: actualHeight,
|
|
6
|
+
result: actualHeight === height,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export async function toHaveHeight(received, height, options = {}) {
|
|
10
|
+
const isNot = this.isNot;
|
|
11
|
+
const { expectation = 'height', verb = 'have' } = this;
|
|
12
|
+
let el = await received;
|
|
13
|
+
let actualHeight;
|
|
14
|
+
const pass = await waitUntil(async () => {
|
|
15
|
+
const result = await executeCommand.call(this, el, condition, options, [height, options]);
|
|
16
|
+
el = result.el;
|
|
17
|
+
actualHeight = result.values;
|
|
18
|
+
return result.success;
|
|
19
|
+
}, isNot, options);
|
|
20
|
+
updateElementsArray(pass, received, el);
|
|
21
|
+
const message = enhanceError(el, wrapExpectedWithArray(el, actualHeight, height), actualHeight, this, verb, expectation, '', options);
|
|
22
|
+
return {
|
|
23
|
+
pass,
|
|
24
|
+
message: () => message,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, updateElementsArray, compareObject, } from '../../utils.js';
|
|
2
|
+
async function condition(el, size) {
|
|
3
|
+
const actualSize = await el.getSize();
|
|
4
|
+
return compareObject(actualSize, size);
|
|
5
|
+
}
|
|
6
|
+
export async function toHaveSize(received, size, options = {}) {
|
|
7
|
+
const isNot = this.isNot;
|
|
8
|
+
const { expectation = 'size', verb = 'have' } = this;
|
|
9
|
+
let el = await received;
|
|
10
|
+
let actualSize;
|
|
11
|
+
const pass = await waitUntil(async () => {
|
|
12
|
+
const result = await executeCommand.call(this, el, condition, options, [size, options]);
|
|
13
|
+
el = result.el;
|
|
14
|
+
actualSize = result.values;
|
|
15
|
+
return result.success;
|
|
16
|
+
}, isNot, options);
|
|
17
|
+
updateElementsArray(pass, received, el);
|
|
18
|
+
const message = enhanceError(el, wrapExpectedWithArray(el, actualSize, size), actualSize, this, verb, expectation, '', options);
|
|
19
|
+
return {
|
|
20
|
+
pass,
|
|
21
|
+
message: () => message,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, updateElementsArray, } from '../../utils.js';
|
|
2
|
+
async function condition(el, width) {
|
|
3
|
+
const actualWidth = await el.getSize('width');
|
|
4
|
+
return {
|
|
5
|
+
value: actualWidth,
|
|
6
|
+
result: actualWidth === width,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export async function toHaveWidth(received, width, options = {}) {
|
|
10
|
+
const isNot = this.isNot;
|
|
11
|
+
const { expectation = 'width', verb = 'have' } = this;
|
|
12
|
+
let el = await received;
|
|
13
|
+
let actualWidth;
|
|
14
|
+
const pass = await waitUntil(async () => {
|
|
15
|
+
const result = await executeCommand.call(this, el, condition, options, [width, options]);
|
|
16
|
+
el = result.el;
|
|
17
|
+
actualWidth = result.values;
|
|
18
|
+
return result.success;
|
|
19
|
+
}, isNot, options);
|
|
20
|
+
updateElementsArray(pass, received, el);
|
|
21
|
+
const message = enhanceError(el, wrapExpectedWithArray(el, actualWidth, width), actualWidth, this, verb, expectation, '', options);
|
|
22
|
+
return {
|
|
23
|
+
pass,
|
|
24
|
+
message: () => message,
|
|
25
|
+
};
|
|
26
|
+
}
|
package/lib/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import isEqual from 'lodash.isequal';
|
|
1
2
|
import { executeCommand } from './util/executeCommand.js';
|
|
2
3
|
import { wrapExpectedWithArray, updateElementsArray } from './util/elementsUtil.js';
|
|
3
4
|
import { enhanceError, enhanceErrorBe, numberError } from './util/formatMessage.js';
|
|
@@ -161,6 +162,18 @@ export const compareTextWithArray = (actual, expectedArray, { ignoreCase = false
|
|
|
161
162
|
result: textInArray
|
|
162
163
|
};
|
|
163
164
|
};
|
|
165
|
+
export const compareObject = (actual, expected) => {
|
|
166
|
+
if (typeof actual !== 'object' || Array.isArray(actual)) {
|
|
167
|
+
return {
|
|
168
|
+
value: actual,
|
|
169
|
+
result: false
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
value: actual,
|
|
174
|
+
result: isEqual(actual, expected)
|
|
175
|
+
};
|
|
176
|
+
};
|
|
164
177
|
export const compareStyle = async (actualEl, style, { ignoreCase = true, trim = false }) => {
|
|
165
178
|
let result = true;
|
|
166
179
|
const actual = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expect-webdriverio",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
|
|
5
5
|
"description": "WebdriverIO Assertion Library",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/debug": "^4.1.8",
|
|
62
62
|
"@types/jest": "^29.5.4",
|
|
63
|
+
"@types/lodash.isequal": "^4.5.6",
|
|
63
64
|
"@types/node": "^20.6.0",
|
|
64
65
|
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
65
66
|
"@typescript-eslint/parser": "^6.7.0",
|
|
@@ -84,6 +85,7 @@
|
|
|
84
85
|
},
|
|
85
86
|
"dependencies": {
|
|
86
87
|
"expect": "^29.7.0",
|
|
87
|
-
"jest-matcher-utils": "^29.7.0"
|
|
88
|
+
"jest-matcher-utils": "^29.7.0",
|
|
89
|
+
"lodash.isequal": "^4.5.0"
|
|
88
90
|
}
|
|
89
91
|
}
|
|
@@ -1,380 +1,469 @@
|
|
|
1
1
|
type searchValue = string | RegExp
|
|
2
2
|
type replaceValue = string | ((substring: string, ...args: any[]) => string)
|
|
3
|
-
type Replacer = [searchValue, replaceValue]
|
|
4
|
-
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
options?: ExpectWebdriverIO.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
options?: ExpectWebdriverIO.StringOptions
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
3
|
+
export type Replacer = [searchValue, replaceValue]
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
namespace ExpectWebdriverIO {
|
|
7
|
+
function expect<T = unknown, R extends void | Promise<void> = void | Promise<void>>(
|
|
8
|
+
actual: T
|
|
9
|
+
): Matchers<R, T>
|
|
10
|
+
function setOptions(options: DefaultOptions): void
|
|
11
|
+
function getConfig(): any
|
|
12
|
+
const matchers: Record<
|
|
13
|
+
string,
|
|
14
|
+
(
|
|
15
|
+
actual: any,
|
|
16
|
+
...expected: any[]
|
|
17
|
+
) => Promise<{
|
|
18
|
+
pass: boolean
|
|
19
|
+
message(): string
|
|
20
|
+
}>
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
interface DefaultOptions {
|
|
24
|
+
/**
|
|
25
|
+
* time in ms to wait for expectation to succeed. Default: 3000
|
|
26
|
+
*/
|
|
27
|
+
wait?: number
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* interval between attempts. Default: 100
|
|
31
|
+
*/
|
|
32
|
+
interval?: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface CommandOptions extends DefaultOptions {
|
|
36
|
+
/**
|
|
37
|
+
* user message to prepend before assertion error
|
|
38
|
+
*/
|
|
39
|
+
message?: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface HTMLOptions extends StringOptions {
|
|
43
|
+
/**
|
|
44
|
+
* return the HTML with the selector tag included
|
|
45
|
+
*/
|
|
46
|
+
includeSelectorTag?: boolean
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface StringOptions extends CommandOptions {
|
|
50
|
+
/**
|
|
51
|
+
* apply `toLowerCase` to both actual and expected values
|
|
52
|
+
*/
|
|
53
|
+
ignoreCase?: boolean
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* apply `trim` to actual value
|
|
57
|
+
*/
|
|
58
|
+
trim?: boolean
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* expect actual value to contain expected value.
|
|
62
|
+
* Otherwise strict equal
|
|
63
|
+
*/
|
|
64
|
+
containing?: boolean
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* expect actual value to start with the expected value
|
|
68
|
+
* Otherwise strict equal
|
|
69
|
+
*/
|
|
70
|
+
atStart?: boolean
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* expect actual value to end with the expected value
|
|
74
|
+
* Otherwise strict equal
|
|
75
|
+
*/
|
|
76
|
+
atEnd?: boolean
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* expect actual value to have the expected value at the given index (index starts at 0 not 1)
|
|
80
|
+
* Otherwise strict equal
|
|
81
|
+
*/
|
|
82
|
+
atIndex?: number
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* replace the actual value (example: strip newlines from the value) and expect it to match the expected value
|
|
86
|
+
* Otherwise strict equal
|
|
87
|
+
*/
|
|
88
|
+
replace?: Replacer | Replacer[]
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* might be helpful to force converting property value to string
|
|
92
|
+
*/
|
|
93
|
+
asString?: boolean
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface NumberOptions extends CommandOptions {
|
|
97
|
+
/**
|
|
98
|
+
* equals
|
|
99
|
+
*/
|
|
100
|
+
eq?: number
|
|
101
|
+
/**
|
|
102
|
+
* less than or equals
|
|
103
|
+
*/
|
|
104
|
+
lte?: number
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* greater than or equals
|
|
108
|
+
*/
|
|
109
|
+
gte?: number
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
113
|
+
interface Matchers<R, T> {
|
|
114
|
+
// ===== $ or $$ =====
|
|
115
|
+
/**
|
|
116
|
+
* `WebdriverIO.Element` -> `isDisplayed`
|
|
117
|
+
*/
|
|
118
|
+
toBeDisplayed(options?: ExpectWebdriverIO.CommandOptions): R
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* `WebdriverIO.Element` -> `isExisting`
|
|
122
|
+
*/
|
|
123
|
+
toExist(options?: ExpectWebdriverIO.CommandOptions): R
|
|
124
|
+
/**
|
|
125
|
+
* `WebdriverIO.Element` -> `isExisting`
|
|
126
|
+
*/
|
|
127
|
+
toBePresent(options?: ExpectWebdriverIO.CommandOptions): R
|
|
128
|
+
/**
|
|
129
|
+
* `WebdriverIO.Element` -> `isExisting`
|
|
130
|
+
*/
|
|
131
|
+
toBeExisting(options?: ExpectWebdriverIO.CommandOptions): R
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* `WebdriverIO.Element` -> `getAttribute`
|
|
135
|
+
*/
|
|
136
|
+
toHaveAttribute(
|
|
137
|
+
attribute: string,
|
|
138
|
+
value?: string | RegExp,
|
|
139
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
140
|
+
): R
|
|
141
|
+
/**
|
|
142
|
+
* `WebdriverIO.Element` -> `getAttribute`
|
|
143
|
+
*/
|
|
144
|
+
toHaveAttr(
|
|
145
|
+
attribute: string,
|
|
146
|
+
value?: string | RegExp,
|
|
147
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
148
|
+
): R
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* `WebdriverIO.Element` -> `getAttribute`
|
|
152
|
+
* Element's attribute includes the value.
|
|
153
|
+
*/
|
|
154
|
+
toHaveAttributeContaining(
|
|
155
|
+
attribute: string,
|
|
156
|
+
contains: string | RegExp,
|
|
157
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
158
|
+
): R
|
|
159
|
+
/**
|
|
160
|
+
* `WebdriverIO.Element` -> `getAttribute`
|
|
161
|
+
* Element's attribute includes the value.
|
|
162
|
+
*/
|
|
163
|
+
toHaveAttrContaining(
|
|
164
|
+
attribute: string,
|
|
165
|
+
contains: string | RegExp,
|
|
166
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
167
|
+
): R
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* `WebdriverIO.Element` -> `getAttribute` class
|
|
171
|
+
* @deprecated since v1.3.1 - use `toHaveElementClass` instead.
|
|
172
|
+
*/
|
|
173
|
+
toHaveClass(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* `WebdriverIO.Element` -> `getAttribute` class
|
|
177
|
+
*/
|
|
178
|
+
toHaveElementClass(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* `WebdriverIO.Element` -> `getAttribute` class
|
|
182
|
+
* @deprecated since v1.3.1 - use `toHaveElementClassContaining` instead.
|
|
183
|
+
* Element's class includes the className.
|
|
184
|
+
*/
|
|
185
|
+
toHaveClassContaining(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* `WebdriverIO.Element` -> `getAttribute` class
|
|
189
|
+
* Element's class includes the className.
|
|
190
|
+
*/
|
|
191
|
+
toHaveElementClassContaining(
|
|
192
|
+
className: string | RegExp,
|
|
193
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
194
|
+
): R
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* `WebdriverIO.Element` -> `getProperty`
|
|
198
|
+
*/
|
|
199
|
+
toHaveElementProperty(
|
|
200
|
+
property: string | RegExp,
|
|
201
|
+
value?: any,
|
|
202
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
203
|
+
): R
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* `WebdriverIO.Element` -> `getProperty` value
|
|
207
|
+
*/
|
|
208
|
+
toHaveValue(value: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
209
|
+
/**
|
|
210
|
+
* `WebdriverIO.Element` -> `getProperty` value
|
|
211
|
+
* Element's value includes the value.
|
|
212
|
+
*/
|
|
213
|
+
toHaveValueContaining(value: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* `WebdriverIO.Element` -> `isClickable`
|
|
217
|
+
*/
|
|
218
|
+
toBeClickable(options?: ExpectWebdriverIO.StringOptions): R
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* `WebdriverIO.Element` -> `!isEnabled`
|
|
222
|
+
*/
|
|
223
|
+
toBeDisabled(options?: ExpectWebdriverIO.StringOptions): R
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* `WebdriverIO.Element` -> `isDisplayedInViewport`
|
|
227
|
+
*/
|
|
228
|
+
toBeDisplayedInViewport(options?: ExpectWebdriverIO.StringOptions): R
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* `WebdriverIO.Element` -> `isEnabled`
|
|
232
|
+
*/
|
|
233
|
+
toBeEnabled(options?: ExpectWebdriverIO.StringOptions): R
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* `WebdriverIO.Element` -> `isFocused`
|
|
237
|
+
*/
|
|
238
|
+
toBeFocused(options?: ExpectWebdriverIO.StringOptions): R
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* `WebdriverIO.Element` -> `isSelected`
|
|
242
|
+
*/
|
|
243
|
+
toBeSelected(options?: ExpectWebdriverIO.StringOptions): R
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* `WebdriverIO.Element` -> `isSelected`
|
|
247
|
+
*/
|
|
248
|
+
toBeChecked(options?: ExpectWebdriverIO.StringOptions): R
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* `WebdriverIO.Element` -> `$$('./*').length`
|
|
252
|
+
* supports less / greater then or equals to be passed in options
|
|
253
|
+
*/
|
|
254
|
+
toHaveChildren(
|
|
255
|
+
size?: number | ExpectWebdriverIO.NumberOptions,
|
|
256
|
+
options?: ExpectWebdriverIO.NumberOptions
|
|
257
|
+
): R
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* `WebdriverIO.Element` -> `getAttribute` href
|
|
261
|
+
*/
|
|
262
|
+
toHaveHref(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
263
|
+
/**
|
|
264
|
+
* `WebdriverIO.Element` -> `getAttribute` href
|
|
265
|
+
*/
|
|
266
|
+
toHaveLink(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* `WebdriverIO.Element` -> `getAttribute` href
|
|
270
|
+
* Element's href includes the value provided
|
|
271
|
+
*/
|
|
272
|
+
toHaveHrefContaining(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
273
|
+
/**
|
|
274
|
+
* `WebdriverIO.Element` -> `getAttribute` href
|
|
275
|
+
* Element's href includes the value provided
|
|
276
|
+
*/
|
|
277
|
+
toHaveLinkContaining(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* `WebdriverIO.Element` -> `getProperty` value
|
|
281
|
+
*/
|
|
282
|
+
toHaveId(id: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* `WebdriverIO.Element` -> `getText`
|
|
286
|
+
* Element's text equals the text provided
|
|
287
|
+
*/
|
|
288
|
+
toHaveText(
|
|
289
|
+
text: string | RegExp | Array<string | RegExp>,
|
|
290
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
291
|
+
): R
|
|
292
|
+
/**
|
|
293
|
+
* `WebdriverIO.Element` -> `getText`
|
|
294
|
+
* Element's text includes the text provided
|
|
295
|
+
*/
|
|
296
|
+
toHaveTextContaining(
|
|
297
|
+
text: string | RegExp | Array<string | RegExp>,
|
|
298
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
299
|
+
): R
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* `WebdriverIO.Element` -> `getHTML`
|
|
303
|
+
* Element's html equals the html provided
|
|
304
|
+
*/
|
|
305
|
+
toHaveHTML(
|
|
306
|
+
html: string | RegExp | Array<string | RegExp>,
|
|
307
|
+
options?: ExpectWebdriverIO.HTMLOptions
|
|
308
|
+
): R
|
|
309
|
+
/**
|
|
310
|
+
* `WebdriverIO.Element` -> `getHTML`
|
|
311
|
+
* Element's html includes the html provided
|
|
312
|
+
*/
|
|
313
|
+
toHaveHTMLContaining(
|
|
314
|
+
html: string | RegExp | Array<string | RegExp>,
|
|
315
|
+
options?: ExpectWebdriverIO.HTMLOptions
|
|
316
|
+
): R
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* `WebdriverIO.Element` -> `getComputedLabel`
|
|
320
|
+
* Element's computed label equals the computed label provided
|
|
321
|
+
*/
|
|
322
|
+
toHaveComputedLabel(
|
|
323
|
+
computedLabel: string | RegExp | Array<string | RegExp>,
|
|
324
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
325
|
+
): R
|
|
326
|
+
/**
|
|
327
|
+
* `WebdriverIO.Element` -> `getComputedLabel`
|
|
328
|
+
* Element's computed label includes the computed label provided
|
|
329
|
+
*/
|
|
330
|
+
toHaveComputedLabelContaining(
|
|
331
|
+
computedLabel: string | RegExp | Array<string | RegExp>,
|
|
332
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
333
|
+
): R
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* `WebdriverIO.Element` -> `getComputedRole`
|
|
337
|
+
* Element's computed role equals the computed role provided
|
|
338
|
+
*/
|
|
339
|
+
toHaveComputedRole(
|
|
340
|
+
computedRole: string | RegExp | Array<string | RegExp>,
|
|
341
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
342
|
+
): R
|
|
343
|
+
/**
|
|
344
|
+
* `WebdriverIO.Element` -> `getComputedRole`
|
|
345
|
+
* Element's computed role includes the computed role provided
|
|
346
|
+
*/
|
|
347
|
+
toHaveComputedRoleContaining(
|
|
348
|
+
computedRole: string | RegExp | Array<string | RegExp>,
|
|
349
|
+
options?: ExpectWebdriverIO.StringOptions
|
|
350
|
+
): R
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* `WebdriverIO.Element` -> `getSize('width')`
|
|
354
|
+
* Element's width equals the width provided
|
|
355
|
+
*/
|
|
356
|
+
toHaveWidth(width: number, options?: ExpectWebdriverIO.CommandOptions): R
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* `WebdriverIO.Element` -> `getSize('height')`
|
|
360
|
+
* Element's height equals the height provided
|
|
361
|
+
*/
|
|
362
|
+
toHaveHeight(height: number, options?: ExpectWebdriverIO.CommandOptions): R
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* `WebdriverIO.Element` -> `getSize()`
|
|
366
|
+
* Element's size equals the size provided
|
|
367
|
+
*/
|
|
368
|
+
toHaveHeight(
|
|
369
|
+
size: { height: number; width: number },
|
|
370
|
+
options?: ExpectWebdriverIO.CommandOptions
|
|
371
|
+
): R
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* `WebdriverIO.Element` -> `getAttribute("style")`
|
|
375
|
+
*/
|
|
376
|
+
toHaveStyle(style: { [key: string]: string }, options?: ExpectWebdriverIO.StringOptions): R
|
|
377
|
+
|
|
378
|
+
// ===== browser only =====
|
|
379
|
+
/**
|
|
380
|
+
* `WebdriverIO.Browser` -> `getUrl`
|
|
381
|
+
*/
|
|
382
|
+
toHaveUrl(url: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
383
|
+
|
|
384
|
+
// ===== browser only =====
|
|
385
|
+
/**
|
|
386
|
+
* `WebdriverIO.Browser` -> `getUrl`
|
|
387
|
+
* Browser's url includes the provided text
|
|
388
|
+
*/
|
|
389
|
+
toHaveUrlContaining(url: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* `WebdriverIO.Browser` -> `getTitle`
|
|
393
|
+
*/
|
|
394
|
+
toHaveTitle(title: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
395
|
+
|
|
396
|
+
// ===== browser only =====
|
|
397
|
+
/**
|
|
398
|
+
* `WebdriverIO.Browser` -> `getTitle`
|
|
399
|
+
* Browser's title includes the provided text
|
|
400
|
+
*/
|
|
401
|
+
toHaveTitleContaining(title: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
402
|
+
|
|
403
|
+
// ===== $$ only =====
|
|
404
|
+
/**
|
|
405
|
+
* `WebdriverIO.ElementArray` -> `$$('...').length`
|
|
406
|
+
* supports less / greater then or equals to be passed in options
|
|
407
|
+
*/
|
|
408
|
+
toBeElementsArrayOfSize(
|
|
409
|
+
size: number | ExpectWebdriverIO.NumberOptions,
|
|
410
|
+
options?: ExpectWebdriverIO.NumberOptions
|
|
411
|
+
): R
|
|
412
|
+
|
|
413
|
+
// ==== network mock ====
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Check that `WebdriverIO.Mock` was called
|
|
417
|
+
*/
|
|
418
|
+
toBeRequested(options?: ExpectWebdriverIO.CommandOptions): R
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Check that `WebdriverIO.Mock` was called N times
|
|
422
|
+
*/
|
|
423
|
+
toBeRequestedTimes(
|
|
424
|
+
times: number | ExpectWebdriverIO.NumberOptions,
|
|
425
|
+
options?: ExpectWebdriverIO.NumberOptions
|
|
426
|
+
): R
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Check that `WebdriverIO.Mock` was called with the specific parameters
|
|
430
|
+
*/
|
|
431
|
+
toBeRequestedWith(requestedWith: RequestedWith, options?: ExpectWebdriverIO.CommandOptions): R
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
type RequestedWith = {
|
|
435
|
+
url?: string | ExpectWebdriverIO.PartialMatcher | ((url: string) => boolean)
|
|
436
|
+
method?: string | Array<string>
|
|
437
|
+
statusCode?: number | Array<number>
|
|
438
|
+
requestHeaders?:
|
|
439
|
+
| Record<string, string>
|
|
440
|
+
| ExpectWebdriverIO.PartialMatcher
|
|
441
|
+
| ((headers: Record<string, string>) => boolean)
|
|
442
|
+
responseHeaders?:
|
|
443
|
+
| Record<string, string>
|
|
444
|
+
| ExpectWebdriverIO.PartialMatcher
|
|
445
|
+
| ((headers: Record<string, string>) => boolean)
|
|
446
|
+
postData?:
|
|
447
|
+
| string
|
|
448
|
+
| ExpectWebdriverIO.JsonCompatible
|
|
449
|
+
| ExpectWebdriverIO.PartialMatcher
|
|
450
|
+
| ((r: string | undefined) => boolean)
|
|
451
|
+
response?:
|
|
452
|
+
| string
|
|
453
|
+
| ExpectWebdriverIO.JsonCompatible
|
|
454
|
+
| ExpectWebdriverIO.PartialMatcher
|
|
455
|
+
| ((r: string) => boolean)
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
type jsonPrimitive = string | number | boolean | null
|
|
459
|
+
type jsonObject = { [x: string]: jsonPrimitive | jsonObject | jsonArray }
|
|
460
|
+
type jsonArray = Array<jsonPrimitive | jsonObject | jsonArray>
|
|
461
|
+
type JsonCompatible = jsonObject | jsonArray
|
|
462
|
+
|
|
463
|
+
interface PartialMatcher {
|
|
464
|
+
sample?: any
|
|
465
|
+
asymmetricMatch?(...args: any[]): boolean
|
|
466
|
+
}
|
|
378
467
|
}
|
|
379
468
|
}
|
|
380
469
|
|