expect-webdriverio 5.7.0 → 6.0.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.
Files changed (41) hide show
  1. package/README.md +16 -14
  2. package/lib/constants.js +4 -0
  3. package/lib/index.js +30 -18
  4. package/lib/matchers/asymmetrics/asymmetricsUtils.js +24 -0
  5. package/lib/matchers/asymmetrics/oneOf.js +51 -0
  6. package/lib/matchers/browser/toHaveClipboardText.js +8 -9
  7. package/lib/matchers/browser/toHaveLocalStorageItem.js +22 -14
  8. package/lib/matchers/browser/toHaveTitle.js +9 -10
  9. package/lib/matchers/browser/toHaveUrl.js +8 -9
  10. package/lib/matchers/element/toBeExisting.js +8 -3
  11. package/lib/matchers/element/toBeSelected.js +6 -13
  12. package/lib/matchers/element/toHaveAttribute.js +46 -45
  13. package/lib/matchers/element/toHaveChildren.js +30 -32
  14. package/lib/matchers/element/toHaveComputedLabel.js +21 -20
  15. package/lib/matchers/element/toHaveComputedRole.js +21 -20
  16. package/lib/matchers/element/toHaveElementClass.js +57 -0
  17. package/lib/matchers/element/toHaveElementProperty.js +40 -32
  18. package/lib/matchers/element/toHaveHTML.js +22 -23
  19. package/lib/matchers/element/toHaveHeight.js +23 -28
  20. package/lib/matchers/element/toHaveSize.js +16 -14
  21. package/lib/matchers/element/toHaveStyle.js +20 -14
  22. package/lib/matchers/element/toHaveText.js +26 -44
  23. package/lib/matchers/element/toHaveWidth.js +23 -28
  24. package/lib/matchers/elements/toBeElementsArrayOfSize.js +25 -30
  25. package/lib/matchers/mock/toBeRequestedTimes.js +12 -17
  26. package/lib/matchers/mock/toBeRequestedWith.js +8 -9
  27. package/lib/matchers/modifiers/some.js +15 -0
  28. package/lib/matchers.js +1 -1
  29. package/lib/tsconfig.build.tsbuildinfo +1 -1
  30. package/lib/util/commandOptionsUtils.js +6 -0
  31. package/lib/util/elementsUtil.js +74 -4
  32. package/lib/util/executeCommand.js +94 -6
  33. package/lib/util/formatMessage.js +87 -32
  34. package/lib/util/numberOptionsUtil.js +92 -0
  35. package/lib/util/refetchElements.js +30 -5
  36. package/lib/util/stringUtil.js +12 -0
  37. package/lib/util/waitUntil.js +44 -0
  38. package/lib/utils.js +84 -91
  39. package/package.json +11 -10
  40. package/types/expect-webdriverio.d.ts +587 -134
  41. package/lib/matchers/element/toHaveClass.js +0 -61
@@ -21,6 +21,9 @@ type ExpectLibAsyncExpectationResult = import('expect').AsyncExpectationResult
21
21
  type ExpectLibExpectationResult = import('expect').ExpectationResult
22
22
  type ExpectLibMatcherContext = import('expect').MatcherContext
23
23
  type MatchersObject = Parameters<typeof import('expect').expect.extend>[0]
24
+ type ExpectLibAnything = ReturnType<typeof expect.any> | ReturnType<typeof expect.anything>
25
+
26
+ type WdioSome<T> = import('../src/matchers/modifiers/some.js').SomeElementsWrapper<T>
24
27
 
25
28
  // Extracted from the expect library, this is the type of the matcher function used in the expect library.
26
29
  type RawMatcherFn<Context extends ExpectLibMatcherContext = ExpectLibMatcherContext> = {
@@ -29,48 +32,72 @@ type RawMatcherFn<Context extends ExpectLibMatcherContext = ExpectLibMatcherCont
29
32
  }
30
33
 
31
34
  /**
32
- * Real Promise and wdio chainable promise types.
35
+ * Indicates that a value can be either one T or an array of T.
33
36
  */
34
- type WdioPromiseLike<T = unknown> = PromiseLike<T> | ChainablePromiseElement | ChainablePromiseArray
35
- type WdioElementOrPromiseLike<T = unknown> = WdioPromiseLike<T> | WebdriverIO.Element
36
- type ElementPromise = Promise<WebdriverIO.Element>
37
- type ElementArrayPromise = Promise<WebdriverIO.ElementArray>
37
+ type MaybeArray<T> = T | T[]
38
+
39
+ type MaybeSome<T> = T | WdioSome<T>
40
+
41
+ /**
42
+ * Indicates that a value can be either one T, an array of T with oneOf of T, or a oneOf matcher of T.
43
+ * For oneOf anything is excluded since it does not make any sense to have a oneOf with Anything matcher.
44
+ * TODO support number in oneOf until then we exclude it from the type to avoid confusion.
45
+ */
46
+ type MaybeArrayOrOneOf<T> = T | (T | ExpectWebdriverIO.OneOfPartialMatcher<Exclude<T, ExpectWebdriverIO.PartialMatcherAnything | number>>)[] | ExpectWebdriverIO.OneOfPartialMatcher<Exclude<T, ExpectWebdriverIO.PartialMatcherAnything | number>>
38
47
 
39
48
  /**
40
- * Only Wdio real promise
49
+ * Indicates that a value can be either one T, or oneOf matchers of T.
50
+ * For oneOf anything is excluded since it does not make any sense to have a oneOf with Anything matcher.
41
51
  */
42
- type WdioOnlyPromiseLike = ElementPromise | ElementArrayPromise | ChainablePromiseElement | ChainablePromiseArray
52
+ type MaybeOneOf<T> = T | ExpectWebdriverIO.OneOfPartialMatcher<Exclude<T, ExpectWebdriverIO.PartialMatcherAnything>>
43
53
 
44
54
  /**
45
- * Only wdio real promise or potential promise usage on element or element array or browser
55
+ * Real Promise and wdio chainable promise types.
46
56
  */
47
- type WdioOnlyMaybePromiseLike = ElementPromise | ElementArrayPromise | ChainablePromiseElement | ChainablePromiseArray | WebdriverIO.Browser | WebdriverIO.Element | WebdriverIO.ElementArray
57
+ type WdioPromiseLike<T = unknown> = PromiseLike<T> | ChainablePromiseElement | ChainablePromiseArray
58
+ type WdioElementOrPromiseLike<T = unknown> = WdioPromiseLike<T> | WebdriverIO.Element
59
+ type ElementPromise = Promise<WebdriverIO.Element>
60
+ type ElementArrayPromise = Promise<WebdriverIO.ElementArray>
61
+ type ArrayOfElementsPromise = Promise<WebdriverIO.Element[]>
48
62
 
49
63
  /**
50
- * Note we are defining Matchers outside of the namespace as done in jest library until we can make every typing work correctly.
64
+ * Note we are defining types outside of the namespace as done in jest library until we can make every typing work correctly.
51
65
  * Once we have all types working, we could check to bring those back into the `ExpectWebdriverIO` namespace.
52
66
  */
53
67
 
54
68
  /**
55
69
  * Type helpers to be able to targets specific types mostly used in conjunctions with the Type of the `actual` parameter of the `expect`
56
70
  */
57
- type ElementOrArrayLike = ElementLike | ElementArrayLike
71
+ type ElementOrMaybeSomeArrayLike = ElementLike | MaybeSomeElementArrayLike
58
72
  type ElementLike = WebdriverIO.Element | ChainablePromiseElement
59
- type ElementArrayLike = WebdriverIO.ElementArray | ChainablePromiseArray | WebdriverIO.Element[]
73
+ type ElementArrayLike = WebdriverIO.ElementArray | ChainablePromiseArray | WebdriverIO.Element[] | ArrayOfElementsPromise | ElementArrayPromise
74
+ type MaybeSomeElementArrayLike = MaybeSome<WebdriverIO.ElementArray | ChainablePromiseArray | WebdriverIO.Element[] | ArrayOfElementsPromise | ElementArrayPromise>
60
75
  type MockPromise = Promise<WebdriverIO.Mock>
61
76
 
62
77
  /**
63
78
  * Type helpers allowing to use the function when the expect(actual: T) is of the expected type T.
64
79
  */
65
80
  type FnWhenBrowser<ActualT, Fn> = ActualT extends WebdriverIO.Browser ? Fn : never
66
- type FnWhenElementOrArrayLike<ActualT, Fn> = ActualT extends ElementOrArrayLike ? Fn : never
67
- type FnWhenElementArrayLike<ActualT, Fn> = ActualT extends ElementArrayLike ? Fn : never
81
+ /**
82
+ * Enables distinct function signatures for single elements versus arrays of elements.
83
+ *
84
+ * Note on Union Types: Passing a union type (e.g., `Element | Element[]`) may cause
85
+ * overload resolution failures, preventing the IDE and compiler from inferring the correct signature.
86
+ *
87
+ * Fix: If type inference issues arise, split the implementation into separate interfaces
88
+ */
89
+ type FnWhenElementOrArrayLike<ActualT, FnElement, FnArray = FnElement> = ActualT extends MaybeSomeElementArrayLike ? FnArray : ActualT extends ElementLike ? FnElement: never
90
+ type FnWhenElementArrayLike<ActualT, Fn> = ActualT extends MaybeSomeElementArrayLike ? Fn : never
68
91
 
69
92
  /**
70
93
  * Same as the other but because of Jasmine and it's expectAsync typing which does not force T to be a promise, then we need to account for `WebdriverIO.Mock
71
94
  */
72
95
  type FnWhenMock<ActualT, Fn> = ActualT extends MockPromise | WebdriverIO.Mock ? Fn : never
73
96
 
97
+ interface WdioCustomAsymmetricMatchers {
98
+ oneOf(...values: Array<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | null>): ExpectWebdriverIO.OneOfPartialMatcher<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | null>
99
+ }
100
+
74
101
  /**
75
102
  * Matchers dedicated to Wdio Browser.
76
103
  * When asserting on a browser's properties requiring to be awaited, the return type is a Promise.
@@ -95,11 +122,23 @@ interface WdioBrowserMatchers<_R, ActualT>{
95
122
  /**
96
123
  * `WebdriverIO.Browser` -> `execute`
97
124
  */
98
- toHaveLocalStorageItem: FnWhenBrowser<ActualT, (
99
- key: string,
100
- expectedValue?: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
101
- options?: ExpectWebdriverIO.StringOptions
102
- ) => Promise<void>>
125
+ toHaveLocalStorageItem: FnWhenBrowser<ActualT, {
126
+ /**
127
+ * @deprecated since v6.0.0, removed in v8.0.0. Use `expect.anything()` instead of `undefined` as expected value.
128
+ */
129
+ (
130
+ key: string,
131
+ expectedValue: undefined,
132
+ options?: ExpectWebdriverIO.StringOptions
133
+ ): Promise<void>,
134
+
135
+ (
136
+ key: string,
137
+ expectedValue?: string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything,
138
+ options?: ExpectWebdriverIO.StringOptions
139
+ ) : Promise<void>
140
+ }
141
+ >
103
142
  }
104
143
 
105
144
  /**
@@ -112,10 +151,25 @@ interface WdioNetworkMatchers<_R, ActualT> {
112
151
  * Check that `WebdriverIO.Mock` was called
113
152
  */
114
153
  toBeRequested: FnWhenMock<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
154
+
115
155
  /**
116
156
  * Check that `WebdriverIO.Mock` was called N times
117
157
  */
118
- toBeRequestedTimes: FnWhenMock<ActualT, (times: number | ExpectWebdriverIO.NumberOptions, options?: ExpectWebdriverIO.NumberOptions) => Promise<void>>
158
+ toBeRequestedTimes: FnWhenMock<ActualT, {
159
+ (
160
+ times: number | ExpectWebdriverIO.NumberMatcher,
161
+ options?: ExpectWebdriverIO.CommandOptions
162
+ ): Promise<void>
163
+
164
+ /**
165
+ * @deprecated since v6.0.0, remove in v8.0.0. Use `NumberMatcher` & `CommandOptions` separately `toBeRequestedTimes(NumberMatcher, options)`.
166
+ */
167
+ (
168
+ times: ExpectWebdriverIO.NumberOptions,
169
+ options?: ExpectWebdriverIO.CommandOptions
170
+ ): Promise<void>;
171
+
172
+ }>
119
173
 
120
174
  /**
121
175
  * Check that `WebdriverIO.Mock` was called with the specific parameters
@@ -151,18 +205,94 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
151
205
  toBeExisting: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
152
206
 
153
207
  /**
154
- * `WebdriverIO.Element` -> `getAttribute`
208
+ * `WebdriverIO.Element` -> `isClickable`
209
+ */
210
+ toBeClickable: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
211
+
212
+ /**
213
+ * `WebdriverIO.Element` -> `!isEnabled`
214
+ */
215
+ toBeDisabled: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
216
+
217
+ /**
218
+ * `WebdriverIO.Element` -> `isDisplayedInViewport`
155
219
  */
156
- toHaveAttribute: FnWhenElementOrArrayLike<ActualT, (
157
- attribute: string, value?: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
158
- options?: ExpectWebdriverIO.StringOptions)
159
- => Promise<void>>
220
+ toBeDisplayedInViewport: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
221
+
222
+ /**
223
+ * `WebdriverIO.Element` -> `isEnabled`
224
+ */
225
+ toBeEnabled: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
226
+
227
+ /**
228
+ * `WebdriverIO.Element` -> `isFocused`
229
+ */
230
+ toBeFocused: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
231
+
232
+ /**
233
+ * `WebdriverIO.Element` -> `isSelected`
234
+ */
235
+ toBeSelected: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
236
+
237
+ /**
238
+ * `WebdriverIO.Element` -> `isSelected`
239
+ */
240
+ toBeChecked: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
241
+
242
+ toHaveAttribute: FnWhenElementOrArrayLike<ActualT, {
243
+ /** Element $() API */
244
+ /**
245
+ * @deprecated since v6.0.0, remove in v8.0.0. Passing explicit `undefined` as a value is deprecated. Omit the second argument entirely or pass options instead: `toHaveAttribute(attribute, options)`.
246
+ */
247
+ (
248
+ attribute: string,
249
+ value: undefined,
250
+ options?: ExpectWebdriverIO.StringOptions
251
+ ): Promise<void>;
252
+
253
+ /** Check ONLY for the presence of the attribute (and optional configuration options) */
254
+ (
255
+ attribute: string,
256
+ ): Promise<void>;
257
+
258
+ /** Assert both attribute name AND a specific expected value */
259
+ (
260
+ attribute: string,
261
+ value: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>> | ExpectWebdriverIO.PartialMatcherAnything,
262
+ options?: ExpectWebdriverIO.StringOptions
263
+ ): Promise<void>;
264
+ }, {
265
+ /** Elements $$() API */
266
+ /**
267
+ * @deprecated Not supported
268
+ */
269
+ (
270
+ attribute: string,
271
+ value: undefined,
272
+ options?: ExpectWebdriverIO.StringOptions
273
+ ): Promise<void>;
274
+
275
+ /** Check ONLY for the presence of the attribute (and optional configuration options) */
276
+ (
277
+ attribute: string,
278
+ ): Promise<void>;
279
+
280
+ /** Assert both attribute name AND a specific expected value */
281
+ (
282
+ attribute: string,
283
+ value: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything>,
284
+ options?: ExpectWebdriverIO.StringOptions
285
+ ): Promise<void>;
286
+ }
287
+ >
160
288
 
161
289
  /**
290
+ * @deprecated since v6.0.0, removed in v8.0.0. Use `toHaveAttribute` instead.
162
291
  * `WebdriverIO.Element` -> `getAttribute`
163
292
  */
164
293
  toHaveAttr: FnWhenElementOrArrayLike<ActualT, (
165
- attribute: string, value?: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
294
+ attribute: string,
295
+ value?: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
166
296
  options?: ExpectWebdriverIO.StringOptions
167
297
  ) => Promise<void>>
168
298
 
@@ -191,106 +321,214 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
191
321
  * await expect(element).toHaveElementClass(['btn', 'btn-large']);
192
322
  * ```
193
323
  */
194
- toHaveElementClass: FnWhenElementOrArrayLike<ActualT, (
195
- className: string | RegExp | Array<string | RegExp> | ExpectWebdriverIO.PartialMatcher<string>,
196
- options?: ExpectWebdriverIO.StringOptions
197
- ) => Promise<void>>
324
+ toHaveElementClass: FnWhenElementOrArrayLike<ActualT, {
325
+ /** Element $() API */
326
+ (
327
+ className: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
328
+ options?: ExpectWebdriverIO.StringOptions
329
+ ) :Promise<void>
330
+ /** @deprecated use `expect.oneOf()` instead of an array */
331
+ (
332
+ className: Array<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
333
+ options?: ExpectWebdriverIO.StringOptions
334
+ ) :Promise<void>
335
+ }, {
336
+ /** Elements $$() API */
337
+ (
338
+ className: MaybeArray<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
339
+ options?: ExpectWebdriverIO.StringOptions
340
+ ) :Promise<void>
341
+ }>
198
342
 
199
- /**
200
- * `WebdriverIO.Element` -> `getProperty`
201
- */
202
- toHaveElementProperty: FnWhenElementOrArrayLike<
203
- ActualT,
343
+ toHaveElementProperty: FnWhenElementOrArrayLike<ActualT, {
344
+ /** Element $() API */
345
+ /**
346
+ * Allow to check ONLY for the presence of the property
347
+ * Use `toHaveElementProperty(property, expect.anything(), options)` to check for the presence of the property with options.
348
+ */
204
349
  (
205
350
  property: string,
206
- value?: string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | null,
207
- options?: ExpectWebdriverIO.StringOptions,
208
- ) => Promise<void>
209
- >
351
+ ): Promise<void>;
210
352
 
211
- /**
212
- * `WebdriverIO.Element` -> `getProperty` value
213
- */
214
- toHaveValue: FnWhenElementOrArrayLike<ActualT, (
215
- value: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
216
- options?: ExpectWebdriverIO.StringOptions
217
- ) => Promise<void>>
353
+ /**
354
+ * @deprecated since v6.0.0, removed in v8.0.0. Passing explicit `undefined` or `null` as a value is deprecated.
355
+ * Omit the second argument entirely or use expect.anything() with options: `toHaveElementProperty(property, expect.anything(), options)`.
356
+ */
357
+ (
358
+ property: string,
359
+ value: undefined | null, // Use expect.any(type) or expect.anything() instead of undefined or null
360
+ options?: ExpectWebdriverIO.StringOptions
361
+ ): Promise<void>;
218
362
 
219
- /**
220
- * `WebdriverIO.Element` -> `isClickable`
221
- */
222
- toBeClickable: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
363
+ /** Assert both property name AND a specific expected value */
364
+ (
365
+ property: string,
366
+ // TODO support `oneOf` for number!
367
+ value: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything> | number,
368
+ options?: ExpectWebdriverIO.StringOptions
369
+ ): Promise<void>;
370
+ }, {
371
+ /** Elements $$() API */
372
+ /**
373
+ * Allow to check ONLY for the presence of the property
374
+ * Use `toHaveElementProperty(property, expect.anything(), options)` to check for the presence of the property with options.
375
+ */
376
+ (
377
+ property: string,
378
+ ): Promise<void>;
223
379
 
224
- /**
225
- * `WebdriverIO.Element` -> `!isEnabled`
226
- */
227
- toBeDisabled: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
380
+ /**
381
+ * @deprecated Not supported
382
+ * Use `expect.anything()` or `[expect.anything()] as value` to check for the presence of the property with options.
383
+ */
384
+ (
385
+ property: string,
386
+ propertyValue: undefined | null, // Use expect.any(type) or expect.anything() instead of undefined or null
387
+ options?: ExpectWebdriverIO.StringOptions
388
+ ): Promise<never>;
228
389
 
229
- /**
230
- * `WebdriverIO.Element` -> `isDisplayedInViewport`
231
- */
232
- toBeDisplayedInViewport: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
390
+ /** Assert both property name AND a specific expected value */
391
+ (
392
+ property: string,
393
+ value: MaybeArrayOrOneOf<string | number | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything | null>,
394
+ options?: ExpectWebdriverIO.StringOptions
395
+ ): Promise<void>;
396
+ }>
233
397
 
234
398
  /**
235
- * `WebdriverIO.Element` -> `isEnabled`
399
+ * `WebdriverIO.Element` -> `getProperty` value
236
400
  */
237
- toBeEnabled: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
401
+ toHaveValue: FnWhenElementOrArrayLike<ActualT,
402
+ /** Element $() API */
403
+ (
238
404
 
239
- /**
240
- * `WebdriverIO.Element` -> `isFocused`
241
- */
242
- toBeFocused: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
405
+ value: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
406
+ options?: ExpectWebdriverIO.StringOptions
407
+ ) => Promise<void>,
243
408
 
244
- /**
245
- * `WebdriverIO.Element` -> `isSelected`
246
- */
247
- toBeSelected: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
409
+ /** Elements $$() API */
410
+ (
248
411
 
249
- /**
250
- * `WebdriverIO.Element` -> `isSelected`
251
- */
252
- toBeChecked: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
412
+ value: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
413
+ options?: ExpectWebdriverIO.StringOptions
414
+ ) => Promise<void>
415
+ >
253
416
 
254
417
  /**
255
418
  * `WebdriverIO.Element` -> `$$('./*').length`
256
- * supports less / greater then or equals to be passed in options
419
+ * Supports less / greater then or equals to be passed in value as a NumberMatcher.
257
420
  */
258
- toHaveChildren: FnWhenElementOrArrayLike<ActualT, (
259
- size?: number | ExpectWebdriverIO.NumberOptions,
260
- options?: ExpectWebdriverIO.NumberOptions
261
- ) => Promise<void>>
421
+ toHaveChildren: FnWhenElementOrArrayLike<ActualT, {
422
+ /** Element $() API */
423
+ /**
424
+ * Verifies that the element has children.
425
+ * Same as `expect(el).toHaveChildren({ gte: 1 })` or `expect(el).toHaveChildren({ gte: 1 }, options)`.
426
+ */
427
+ (): Promise<void>;
428
+ /**
429
+ * @deprecated since 6.0.0, remove in v8.0.0.
430
+ * Passing explicit `undefined` or `{ wait : 1 }` (NumberOptions) as a value is deprecated.
431
+ * Use options with `toHaveChildren({ gte: 1 }, options)`.
432
+ */
433
+ (
434
+ expectedValue: undefined, // {} also deprecated but we cannot use it as a type because it would match any object
435
+ options?: ExpectWebdriverIO.CommandOptions
436
+ ): Promise<void>;
437
+
438
+ /**
439
+ * When called with an expected child count or number matcher.
440
+ */
441
+ (
442
+ expectedValue: number | ExpectWebdriverIO.NumberMatcher,
443
+ options?: ExpectWebdriverIO.CommandOptions
444
+ ): Promise<void>;
445
+
446
+ /**
447
+ * @deprecated since 6.0.0, remove in v8.0.0.
448
+ * NumberOptions is no longer supported. Use `expect(el).toHaveChildren(numberMatcher, options)` instead.
449
+ * Instead of `expect(el).toHaveChildren({ wait: 1 })` use `expect(el).toHaveChildren({ gte: 1 }, { wait: 1 })`.
450
+ */
451
+ (
452
+ expectedValue: ExpectWebdriverIO.NumberOptions,
453
+ options?: ExpectWebdriverIO.CommandOptions
454
+ ): Promise<void>;
455
+ }, {
456
+ /** Element $$() API */
457
+ /**
458
+ * Verifies that the element has children.
459
+ * Same as `expect(el).toHaveChildren({ gte: 1 })` or `expect(el).toHaveChildren({ gte: 1 }, options)`.
460
+ */
461
+ (): Promise<void>;
462
+
463
+ /**
464
+ * @deprecated Not supported
465
+ * NumberOptions is no longer supported. Use `expect(el).toHaveChildren(numberMatcher, options)` instead.
466
+ * Instead of `expect(el).toHaveChildren({ wait: 1 })` use `expect(el).toHaveChildren({ gte: 1 }, { wait: 1 })`.
467
+ */
468
+ (
469
+ expectedValue: undefined,
470
+ options?: ExpectWebdriverIO.CommandOptions
471
+ ): Promise<void>;
472
+
473
+ /**
474
+ * When called with an expected child count or number matcher.
475
+ */
476
+ (
477
+ expectedValue: MaybeArray<number | ExpectWebdriverIO.NumberMatcher>,
478
+ options?: ExpectWebdriverIO.CommandOptions
479
+ ): Promise<void>;
480
+ }>
262
481
 
263
482
  /**
264
483
  * `WebdriverIO.Element` -> `getAttribute` href
265
484
  */
266
- toHaveHref: FnWhenElementOrArrayLike<ActualT, (
267
- href: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
268
- options?: ExpectWebdriverIO.StringOptions
269
- ) => Promise<void>>
485
+ toHaveHref: FnWhenElementOrArrayLike<ActualT, {
486
+ /** Element $() API */
487
+ (
488
+ href: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
489
+ options?: ExpectWebdriverIO.StringOptions
490
+ ) : Promise<void>
491
+ }, {
492
+ /** Elements $$() API */
493
+ (
494
+ href: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
495
+ options?: ExpectWebdriverIO.StringOptions
496
+ ) : Promise<void>
497
+ }>
270
498
 
271
499
  /**
272
500
  * `WebdriverIO.Element` -> `getAttribute` href
273
501
  */
274
- toHaveLink: FnWhenElementOrArrayLike<ActualT, (
275
- href: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
276
- options?: ExpectWebdriverIO.StringOptions
277
- ) => Promise<void>>
502
+ toHaveLink: FnWhenElementOrArrayLike<ActualT, {
503
+ /** Element $() API */
504
+ (
505
+ href: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
506
+ options?: ExpectWebdriverIO.StringOptions
507
+ ) : Promise<void>
508
+ }, {
509
+ /** Elements $$() API */
510
+ (
511
+ href: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
512
+ options?: ExpectWebdriverIO.StringOptions
513
+ ) : Promise<void>
514
+ }>
278
515
 
279
516
  /**
280
517
  * `WebdriverIO.Element` -> `getProperty` value
281
518
  */
282
- toHaveId: FnWhenElementOrArrayLike<ActualT, (
283
- id: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
284
- options?: ExpectWebdriverIO.StringOptions
285
- ) => Promise<void>>
519
+ toHaveId: FnWhenElementOrArrayLike<ActualT,
520
+ /** Element $() API */
521
+ (
522
+ id: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
523
+ options?: ExpectWebdriverIO.StringOptions
524
+ ) => Promise<void>,
286
525
 
287
- /**
288
- * `WebdriverIO.Element` -> `getSize` value
289
- */
290
- toHaveSize: FnWhenElementOrArrayLike<ActualT, (
291
- size: { height: number; width: number },
292
- options?: ExpectWebdriverIO.StringOptions
293
- ) => Promise<void>>
526
+ /** Elements $$() API */
527
+ (
528
+ id: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
529
+ options?: ExpectWebdriverIO.StringOptions
530
+ ) => Promise<void>
531
+ >
294
532
 
295
533
  /**
296
534
  * `WebdriverIO.Element` -> `getText`
@@ -311,66 +549,191 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
311
549
  * await expect(elem).toHaveText(['Coffee', 'Tea', 'Milk'])
312
550
  * ```
313
551
  */
314
- toHaveText: FnWhenElementOrArrayLike<ActualT, (
315
- text: string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | Array<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
316
- options?: ExpectWebdriverIO.StringOptions
317
- ) => Promise<void>>
552
+ toHaveText: FnWhenElementOrArrayLike<ActualT, {
553
+ /** Element $() API */
554
+ (
555
+ text: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
556
+ options?: ExpectWebdriverIO.StringOptions
557
+ ) : Promise<void>
558
+ /** @deprecated Use `expect.oneOf()` instead. */
559
+ (
560
+ text: Array<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
561
+ options?: ExpectWebdriverIO.StringOptions
562
+ ) : Promise<void>
563
+ }, {
564
+ /** Elements $$() API */
565
+ (
566
+ text: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
567
+ options?: ExpectWebdriverIO.StringOptions
568
+ ) : Promise<void>
569
+ }>
318
570
 
319
571
  /**
320
572
  * `WebdriverIO.Element` -> `getHTML`
321
573
  * Element's html equals the html provided
322
574
  */
323
- toHaveHTML: FnWhenElementOrArrayLike<ActualT, (
324
- html: string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | Array<string | RegExp>,
325
- options?: ExpectWebdriverIO.HTMLOptions
326
- ) => Promise<void>>
575
+ toHaveHTML: FnWhenElementOrArrayLike<ActualT, {
576
+ /** Element $() API */
577
+ (
578
+ text: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
579
+ options?: ExpectWebdriverIO.HTMLOptions
580
+ ) : Promise<void>
581
+ /** @deprecated to replace by oneOf() or anyOf() when available */
582
+ (
583
+ text: Array<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
584
+ options?: ExpectWebdriverIO.HTMLOptions
585
+ ) : Promise<void>
586
+ }, {
587
+ /** Elements $$() API */
588
+ (
589
+ text: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.OneOfPartialMatcher<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>>,
590
+ options?: ExpectWebdriverIO.HTMLOptions
591
+ ): Promise<void>
592
+ }>
327
593
 
328
594
  /**
329
595
  * `WebdriverIO.Element` -> `getComputedLabel`
330
596
  * Element's computed label equals the computed label provided
331
597
  */
332
- toHaveComputedLabel: FnWhenElementOrArrayLike<ActualT, (
333
- computedLabel: string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | Array<string | RegExp>,
334
- options?: ExpectWebdriverIO.StringOptions
335
- ) => Promise<void>>
598
+ toHaveComputedLabel: FnWhenElementOrArrayLike<ActualT, {
599
+ /** Element $() API */
600
+ (
601
+ computedLabel: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
602
+ options?: ExpectWebdriverIO.StringOptions
603
+ ) : Promise<void>
604
+
605
+ /** @deprecated use `expect.oneOf()` instead of an array */
606
+ (
607
+ computedLabel: Array<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
608
+ options?: ExpectWebdriverIO.StringOptions
609
+ ) : Promise<void>
610
+ }, {
611
+ /** Elements $$() API */
612
+ (
613
+ computedLabel: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
614
+ options?: ExpectWebdriverIO.StringOptions
615
+ ) : Promise<void>
616
+ }>
336
617
 
337
618
  /**
338
619
  * `WebdriverIO.Element` -> `getComputedRole`
339
620
  * Element's computed role equals the computed role provided
340
621
  */
341
- toHaveComputedRole: FnWhenElementOrArrayLike<ActualT, (
342
- computedRole: string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | Array<string | RegExp>,
343
- options?: ExpectWebdriverIO.StringOptions
344
- ) => Promise<void>>
622
+ toHaveComputedRole: FnWhenElementOrArrayLike<ActualT, {
623
+ /** Element $() API */
624
+ (
625
+ computedRole: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
626
+ options?: ExpectWebdriverIO.StringOptions
627
+ ) : Promise<void>
628
+
629
+ /** @deprecated use `expect.oneOf()` instead of an array */
630
+ (
631
+ computedRole: Array<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
632
+ options?: ExpectWebdriverIO.StringOptions
633
+ ) : Promise<void>
634
+ }, {
635
+ /** Elements $$() API */
636
+ (
637
+ computedRole: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
638
+ options?: ExpectWebdriverIO.StringOptions
639
+ ) : Promise<void>
640
+ }>
345
641
 
346
642
  /**
347
643
  * `WebdriverIO.Element` -> `getSize('width')`
348
644
  * Element's width equals the width provided
349
645
  */
350
- toHaveWidth: FnWhenElementOrArrayLike<ActualT, (width: number, options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
646
+ toHaveWidth: FnWhenElementOrArrayLike<ActualT, {
647
+ /** Element $() API */
648
+ (
649
+ width: number | ExpectWebdriverIO.NumberMatcher,
650
+ options?: ExpectWebdriverIO.CommandOptions
651
+ ) : Promise<void>,
652
+
653
+ /**
654
+ * @deprecated since v6.0.0, remove in v8.0.0. Use `toHaveWidth` with number | NumberMatcher instead. This matcher will be removed in version 8.0.0.
655
+ */
656
+ (
657
+ size: ExpectWebdriverIO.NumberOptions,
658
+ options?: ExpectWebdriverIO.CommandOptions
659
+ ): Promise<void>,
660
+ }, {
661
+ /** Elements $$() API */
662
+ (
663
+ width: MaybeArray<number | ExpectWebdriverIO.NumberMatcher>,
664
+ options?: ExpectWebdriverIO.CommandOptions
665
+ ) : Promise<void>
666
+ }>
351
667
 
352
668
  /**
353
- * `WebdriverIO.Element` -> `getSize('height')` or `getSize()`
354
- * Checks if the element's height equals the given number, or its size equals the given object.
669
+ * `WebdriverIO.Element` -> `getSize('height')`
670
+ * Checks if the element's height equals the given number.
355
671
  *
356
- * @param heightOrSize - Either a number (height) or an object with height and width.
672
+ * @param height - The expected height of the element.
357
673
  * @param options - Optional command options.
358
674
  *
359
675
  * **Usage Example:**
360
676
  * ```js
361
677
  * await expect(element).toHaveHeight(42)
362
- * await expect(element).toHaveHeight({ height: 42, width: 42 })
363
678
  * ```
364
679
  */
365
- toHaveHeight: FnWhenElementOrArrayLike<ActualT, (
366
- heightOrSize: number | { height: number; width: number },
367
- options?: ExpectWebdriverIO.CommandOptions
368
- ) => Promise<void>>
680
+ toHaveHeight: FnWhenElementOrArrayLike<ActualT, {
681
+ /** Element $() API */
682
+ (
683
+ height: number | ExpectWebdriverIO.NumberMatcher,
684
+ options?: ExpectWebdriverIO.CommandOptions
685
+ ) : Promise<void>
686
+
687
+ /**
688
+ * @deprecated since v6.0.0, will be removed in version v8.0.0. Use `toHaveHeight` with number | NumberMatcher instead.
689
+ */
690
+ (
691
+ size: ExpectWebdriverIO.NumberOptions,
692
+ options?: ExpectWebdriverIO.CommandOptions
693
+ ): Promise<void>,
694
+ }, {
695
+ /** Elements $$() API */
696
+ (
697
+ height: MaybeArray<number | ExpectWebdriverIO.NumberMatcher>,
698
+ options?: ExpectWebdriverIO.CommandOptions
699
+ ) : Promise<void>
700
+ }>
701
+
702
+ /**
703
+ * `WebdriverIO.Element` -> `getSize` value
704
+ * Element's size equals the size provided
705
+ * // TODO: add support for NumberMatcher on width and height
706
+ */
707
+ toHaveSize: FnWhenElementOrArrayLike<ActualT, {
708
+ /** Element $() API */
709
+ (
710
+ size: { height: number; width: number },
711
+ options?: ExpectWebdriverIO.CommandOptions
712
+ ) : Promise<void>
713
+ }, {
714
+ /** Elements $$() API */
715
+ (
716
+ size: MaybeArray<{ height: number; width: number }>,
717
+ options?: ExpectWebdriverIO.CommandOptions
718
+ ) : Promise<void>
719
+ }>
369
720
 
370
721
  /**
371
722
  * `WebdriverIO.Element` -> `getAttribute("style")`
372
723
  */
373
- toHaveStyle: FnWhenElementOrArrayLike<ActualT, (style: { [key: string]: string }, options?: ExpectWebdriverIO.StringOptions) => Promise<void>>
724
+ toHaveStyle: FnWhenElementOrArrayLike<ActualT, {
725
+ /** Element $() API */
726
+ (
727
+ style: { [key: string]: string },
728
+ options?: ExpectWebdriverIO.StringOptions
729
+ ) : Promise<void>
730
+ }, {
731
+ /** Elements $$() API */
732
+ (
733
+ style: MaybeArray<{ [key: string]: string }>,
734
+ options?: ExpectWebdriverIO.StringOptions
735
+ ) : Promise<void>
736
+ }>
374
737
  }
375
738
 
376
739
  /**
@@ -379,15 +742,26 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
379
742
  * When actual is not of WebdriverIO.ElementArray nor ChainableElementArray, the return type is never, so the function cannot be used.
380
743
  */
381
744
  interface WdioElementArrayOnlyMatchers<_R, ActualT = unknown> {
382
- // ===== $$ only =====
745
+ // ===== Elements $$() only =====
383
746
  /**
384
747
  * `WebdriverIO.ElementArray` -> `$$('...').length`
385
- * supports less / greater then or equals to be passed in options
748
+ * The element arrays is refreshed/mutated until the size equals the size provided or matches the number matcher.
749
+ *
386
750
  */
387
- toBeElementsArrayOfSize: FnWhenElementArrayLike<ActualT, (
388
- size: number | ExpectWebdriverIO.NumberOptions,
389
- options?: ExpectWebdriverIO.NumberOptions
390
- ) => Promise<void> & Promise<WebdriverIO.ElementArray>>
751
+ toBeElementsArrayOfSize: FnWhenElementArrayLike<ActualT, {
752
+ (
753
+ size: number | ExpectWebdriverIO.NumberMatcher,
754
+ options?: ExpectWebdriverIO.CommandOptions
755
+ ): Promise<void>,
756
+
757
+ /**
758
+ * @deprecated since v6.0.0, remove in v8.0.0. Use `toBeElementsArrayOfSize` with number | NumberMatcher instead. This matcher will be removed in version 8.0.0.
759
+ */
760
+ (
761
+ size: ExpectWebdriverIO.NumberOptions,
762
+ options?: ExpectWebdriverIO.CommandOptions
763
+ ): Promise<void>,
764
+ }>
391
765
  }
392
766
 
393
767
  /**
@@ -471,6 +845,10 @@ type WdioAsymmetricMatcher<R> = ExpectWebdriverIO.PartialMatcher<R> & {
471
845
  inverse?: boolean;
472
846
  }
473
847
 
848
+ type WdioOneOfAsymmetricMatcher<R> = ExpectWebdriverIO.PartialMatcher<R> & {
849
+ sample: [R];
850
+ }
851
+
474
852
  type JasmineBaseAsymmetricMatcher = {
475
853
  jasmineToString(): string;
476
854
  asymmetricMatch(other: unknown): boolean;
@@ -501,8 +879,12 @@ type JasmineStringMatchingAsymmetricMatcher<R extends string | RegExp> = Jasmine
501
879
 
502
880
  type JasmineStringAsymmetricMatcher<R extends string | RegExp> = JasmineStringContainingAsymmetricMatcher<R> | JasmineStringMatchingAsymmetricMatcher<R>
503
881
 
882
+ type JasmineAnythingAsymmetricMatcher = JasmineBaseAsymmetricMatcher & {}
883
+
504
884
  type AsymmetricMatcher<R> = WdioAsymmetricMatcher<R> | JasmineStringContainingAsymmetricMatcher<R> | (R extends string | RegExp ? JasmineStringMatchingAsymmetricMatcher<R> : never) | JasmineAsymmetricMatcher<R>
505
885
 
886
+ type WdioAnythingAsymmetricMatcher = ExpectLibAnything | JasmineAnythingAsymmetricMatcher
887
+
506
888
  declare namespace ExpectWebdriverIO {
507
889
  /**
508
890
  * When importing expect from 'expect-webdriverio', instead of using globals this is the one used.
@@ -513,9 +895,22 @@ declare namespace ExpectWebdriverIO {
513
895
  /**
514
896
  * Used by the webdriverio main project to configure the matchers in the runner.
515
897
  */
898
+ function setDefaultOptions(options: DefaultOptions): void
899
+ /** @deprecated since v6.0.0, use setDefaultOptions instead, will be removed in v8.0.0 */
516
900
  function setOptions(options: DefaultOptions): void
517
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
518
- function getConfig(): any
901
+
902
+ /**
903
+ * Allow to enable some new features in the expect-webdriverio library.
904
+ * @param flags
905
+ */
906
+ function setFeatureFlags(flags: FeatureFlags): void
907
+
908
+ /**
909
+ * Get the default options set by the user.
910
+ */
911
+ function getDefaultOptions(): DefaultOptions
912
+ /** @deprecated since v6.0.0, use getDefaultOptions instead, will be removed in v8.0.0 */
913
+ function getConfig(): DefaultOptions
519
914
 
520
915
  /**
521
916
  * The below block are overloaded types from the expect library.
@@ -553,9 +948,9 @@ declare namespace ExpectWebdriverIO {
553
948
  */
554
949
  interface Matchers<R extends void | Promise<void>, T> extends WdioCustomMatchers<R, T> {}
555
950
 
556
- interface AsymmetricMatchers extends WdioAsymmetricMatchers {}
951
+ interface AsymmetricMatchers extends WdioAsymmetricMatchers, WdioCustomAsymmetricMatchers {}
557
952
 
558
- interface InverseAsymmetricMatchers extends Omit<ExpectWebdriverIO.AsymmetricMatchers, 'anything' | 'any'> {}
953
+ interface InverseAsymmetricMatchers extends Omit<ExpectWebdriverIO.AsymmetricMatchers, 'anything' | 'any' | 'oneOf'> {}
559
954
 
560
955
  /**
561
956
  * End of block overloading types from the expect library.
@@ -634,7 +1029,7 @@ declare namespace ExpectWebdriverIO {
634
1029
  const wdioCustomMatchers: MatchersObject
635
1030
 
636
1031
  /**
637
- * @deprecated use `wdioCustomMatchers` instead
1032
+ * @deprecated since 5.6.9 use `wdioCustomMatchers` instead, will be removed in v8.0.0?
638
1033
  */
639
1034
  const matchers: Map<string, RawMatcherFn>
640
1035
 
@@ -664,6 +1059,16 @@ declare namespace ExpectWebdriverIO {
664
1059
  result: AssertionResult
665
1060
  }
666
1061
 
1062
+ interface FeatureFlags {
1063
+ /**
1064
+ * Feature flag to enable the new multi-elements comparison for `toHaveText` matcher, allowing to keep the current behavior without breaking changes.
1065
+ * When enabled, the matcher will compare the text of multiple elements in an indexed exact match manner, rather than using the array as a possible match for any of the elements.
1066
+ *
1067
+ * Will be removed in v6.0.0, as the new behavior will become the default and only behavior for `toHaveText` matcher.
1068
+ */
1069
+ useToHaveTextStrictMultiElementsCompareStrategy?: boolean
1070
+ }
1071
+
667
1072
  interface DefaultOptions {
668
1073
  /**
669
1074
  * time in ms to wait for expectation to succeed. Default: 3000
@@ -684,6 +1089,8 @@ declare namespace ExpectWebdriverIO {
684
1089
  * hook that gets executed after each assertion, it contains the result of the assertion
685
1090
  */
686
1091
  afterAssertion?: (params: AfterAssertionHookParams) => Promise<void>
1092
+
1093
+ featureFlags?: FeatureFlags
687
1094
  }
688
1095
 
689
1096
  interface CommandOptions extends DefaultOptions {
@@ -742,16 +1149,23 @@ declare namespace ExpectWebdriverIO {
742
1149
  replace?: [string | RegExp, string | Function] | Array<[string | RegExp, string | Function]>
743
1150
 
744
1151
  /**
745
- * might be helpful to force converting property value to string
1152
+ * convert element's property value to string
746
1153
  */
747
1154
  asString?: boolean
748
1155
  }
749
1156
 
1157
+ /**
1158
+ * @deprecated since v6.0.0, remove in v8.0.0. Use `NumberMatcher` & `CommandOptions` as separate parameters instead.
1159
+ * @see NumberMatcher
1160
+ * @see CommandOptions
1161
+ */
750
1162
  interface NumberOptions extends CommandOptions {
1163
+
751
1164
  /**
752
1165
  * equals
753
1166
  */
754
1167
  eq?: number
1168
+
755
1169
  /**
756
1170
  * less than or equals
757
1171
  */
@@ -790,6 +1204,22 @@ declare namespace ExpectWebdriverIO {
790
1204
  visibilityProperty?: boolean
791
1205
  }
792
1206
 
1207
+ interface NumberMatcher {
1208
+ /**
1209
+ * equals
1210
+ */
1211
+ eq?: number
1212
+ /**
1213
+ * less than or equals
1214
+ */
1215
+ lte?: number
1216
+
1217
+ /**
1218
+ * greater than or equals
1219
+ */
1220
+ gte?: number
1221
+ }
1222
+
793
1223
  type RequestedWith = {
794
1224
  url?: string | ExpectWebdriverIO.PartialMatcher<string>| ((url: string) => boolean)
795
1225
  method?: string | Array<string>
@@ -824,6 +1254,29 @@ declare namespace ExpectWebdriverIO {
824
1254
  * Some properties are omitted for the type check to work correctly.
825
1255
  */
826
1256
  type PartialMatcher<T> = Omit<ExpectLibAsymmetricMatcher<T>, 'sample' | 'inverse' | '$$typeof'>
1257
+
1258
+ /**
1259
+ * Allow to match any defined value or any defined value of a given type and simply validate a value exists.
1260
+ */
1261
+ type PartialMatcherAnything = ExpectLibAnything | JasmineAnythingAsymmetricMatcher
1262
+
1263
+ /**
1264
+ * Allow to match one of the specified value.
1265
+ */
1266
+ type OneOfPartialMatcher<T> = ExpectWebdriverIO.PartialMatcher<T[]>
1267
+
1268
+ /**
1269
+ * Quantifier modifier. Wraps a `$$()` result so that the matcher passes
1270
+ * when at least one element satisfies the condition (∃ semantics).
1271
+ *
1272
+ * @example
1273
+ * await expect(some($$('.items'))).toBeDisplayed()
1274
+ * await expect(some($$('.items'))).not.toBeDisplayed() // at least one is NOT displayed
1275
+ * await expect(some($$('.items'))).toHaveText('foo')
1276
+ */
1277
+ function some<T extends ElementArrayLike>(
1278
+ elements: T
1279
+ ): WdioSome<T>
827
1280
  }
828
1281
 
829
1282
  declare module 'expect-webdriverio' {