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