expect-webdriverio 6.1.0 → 7.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 (38) hide show
  1. package/README.md +16 -5
  2. package/jest.d.ts +4 -2
  3. package/lib/api/index.js +2 -0
  4. package/lib/index.js +2 -0
  5. package/lib/matchers/asymmetrics/asymmetricsUtils.js +10 -0
  6. package/lib/matchers/asymmetrics/multiRemote.js +36 -0
  7. package/lib/matchers/browser/toHaveClipboardText.js +18 -8
  8. package/lib/matchers/browser/toHaveLocalStorageItem.js +22 -11
  9. package/lib/matchers/browser/toHaveTitle.js +16 -6
  10. package/lib/matchers/browser/toHaveUrl.js +16 -6
  11. package/lib/matchers/element/toHaveAttribute.js +2 -2
  12. package/lib/matchers/element/toHaveChildren.js +4 -3
  13. package/lib/matchers/element/toHaveComputedLabel.js +4 -4
  14. package/lib/matchers/element/toHaveComputedRole.js +4 -4
  15. package/lib/matchers/element/toHaveElementClass.js +4 -4
  16. package/lib/matchers/element/toHaveElementProperty.js +4 -4
  17. package/lib/matchers/element/toHaveHTML.js +4 -4
  18. package/lib/matchers/element/toHaveHeight.js +2 -2
  19. package/lib/matchers/element/toHaveSize.js +3 -3
  20. package/lib/matchers/element/toHaveStyle.js +3 -3
  21. package/lib/matchers/element/toHaveText.js +5 -5
  22. package/lib/matchers/element/toHaveValue.js +1 -1
  23. package/lib/matchers/element/toHaveWidth.js +2 -2
  24. package/lib/matchers/elements/toBeElementsArrayOfSize.js +70 -3
  25. package/lib/matchers/mock/toBeRequestedTimes.js +28 -5
  26. package/lib/matchers/mock/toBeRequestedWith.js +40 -12
  27. package/lib/matchers/snapshot.js +38 -7
  28. package/lib/tsconfig.build.tsbuildinfo +1 -1
  29. package/lib/util/elementsUtil.js +34 -6
  30. package/lib/util/executeBrowserCommand.js +37 -0
  31. package/lib/util/executeCommand.js +107 -19
  32. package/lib/util/formatMessage.js +80 -6
  33. package/lib/util/multiRemoteUtils.js +85 -0
  34. package/lib/util/numberOptionsUtil.js +6 -0
  35. package/lib/util/refetchElements.js +24 -2
  36. package/lib/utils.js +7 -2
  37. package/package.json +3 -3
  38. package/types/expect-webdriverio.d.ts +384 -39
@@ -54,6 +54,17 @@ type MaybeArrayOrOneOf<T> = T | (T | ExpectWebdriverIO.OneOfPartialMatcher<Exclu
54
54
  */
55
55
  type MaybeOneOf<T> = T | ExpectWebdriverIO.OneOfPartialMatcher<Exclude<T, ExpectWebdriverIO.PartialMatcherAnything>>
56
56
 
57
+ type MultiRemoteValues<T> = Record<string, T>
58
+ type MultiRemoteValuesOrOneOf<T> = T | ExpectWebdriverIO.OneOfPartialMatcher<T> | MultiRemoteValues<T | ExpectWebdriverIO.OneOfPartialMatcher<T>> | ExpectWebdriverIO.MultiRemotePartialMatcher<T | ExpectWebdriverIO.OneOfPartialMatcher<T>>
59
+ type MaybeArrayOrMultiRemoteValues<T> = MaybeArray<T> | MultiRemoteValues<T>
60
+ type MaybeArrayOrMultiRemoteValuesOrOneOf<T> = MaybeArray<T | ExpectWebdriverIO.OneOfPartialMatcher<T>> | MultiRemoteValues<T | ExpectWebdriverIO.OneOfPartialMatcher<T>> | ExpectWebdriverIO.OneOfPartialMatcher<T>
61
+ type MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<T> = MaybeArray<T | ExpectWebdriverIO.OneOfPartialMatcher<T>> | MultiRemoteValues<MaybeArray<T | ExpectWebdriverIO.OneOfPartialMatcher<T>>> | ExpectWebdriverIO.OneOfPartialMatcher<T> | ExpectWebdriverIO.MultiRemotePartialMatcher<MaybeArray<T | ExpectWebdriverIO.OneOfPartialMatcher<T>>>
62
+ type ArrayOrMultiRemoteValues<T> = T[] | MultiRemoteValues<T>
63
+ /** Multi-remote $(): one expected value for every instance, or one per instance with `expect.multiRemote()` (e.g. numbers, styles) */
64
+ type SingleOrMultiRemoteMatcher<T> = T | ExpectWebdriverIO.MultiRemotePartialMatcher<T>
65
+ /** Multi-remote $$(): one expected value (or one per element) for every instance, or the same per instance with `expect.multiRemote()` (e.g. numbers, styles) */
66
+ type MaybeArrayOrMultiRemoteMatcher<T> = MaybeArray<T> | ExpectWebdriverIO.MultiRemotePartialMatcher<MaybeArray<T>>
67
+
57
68
  /**
58
69
  * Real Promise and wdio chainable promise types.
59
70
  */
@@ -73,14 +84,18 @@ type ArrayOfElementsPromise = Promise<WebdriverIO.Element[]>
73
84
  */
74
85
  type ElementOrMaybeSomeArrayLike = ElementLike | MaybeSomeElementArrayLike
75
86
  type ElementLike = WebdriverIO.Element | ChainablePromiseElement
76
- type ElementArrayLike = WebdriverIO.ElementArray | ChainablePromiseArray | WebdriverIO.Element[] | ArrayOfElementsPromise | ElementArrayPromise
77
- type MaybeSomeElementArrayLike = MaybeSome<WebdriverIO.ElementArray | ChainablePromiseArray | WebdriverIO.Element[] | ArrayOfElementsPromise | ElementArrayPromise>
87
+ type ElementArrayLike = WebdriverIO.ElementArray | ChainablePromiseArray | WebdriverIO.Element[] | ArrayOfElementsPromise | ElementArrayPromise | WebdriverIO.MultiRemoteElement[]
88
+ type MaybeSomeElementArrayLike = MaybeSome<WebdriverIO.ElementArray | ChainablePromiseArray | WebdriverIO.Element[] | ArrayOfElementsPromise | ElementArrayPromise | WebdriverIO.MultiRemoteElement[]>
89
+ type MultiRemoteElementOrElements = WebdriverIO.MultiRemoteElement | WebdriverIO.MultiRemoteElement[]
78
90
  type MockPromise = Promise<WebdriverIO.Mock>
91
+ /** Multi-remote `mock()`, one mock per instance: every instance's mock must satisfy the network matcher */
92
+ type MultiRemoteMocks = WebdriverIO.Mock[] | Promise<WebdriverIO.Mock[]>
79
93
 
80
94
  /**
81
95
  * Type helpers allowing to use the function when the expect(actual: T) is of the expected type T.
82
96
  */
83
97
  type FnWhenBrowser<ActualT, Fn> = ActualT extends WebdriverIO.Browser ? Fn : never
98
+ type FnWhenBrowserOrMultiRemote<ActualT, FnBrowser, FnMultiRemote> = ActualT extends WebdriverIO.Browser ? FnBrowser : ActualT extends WebdriverIO.MultiRemoteBrowser ? FnMultiRemote : never
84
99
  /**
85
100
  * Enables distinct function signatures for single elements versus arrays of elements.
86
101
  *
@@ -89,58 +104,131 @@ type FnWhenBrowser<ActualT, Fn> = ActualT extends WebdriverIO.Browser ? Fn : nev
89
104
  *
90
105
  * Fix: If type inference issues arise, split the implementation into separate interfaces
91
106
  */
92
- type FnWhenElementOrArrayLike<ActualT, FnElement, FnArray = FnElement> = ActualT extends MaybeSomeElementArrayLike ? FnArray : ActualT extends ElementLike ? FnElement: never
93
- type FnWhenElementArrayLike<ActualT, Fn> = ActualT extends MaybeSomeElementArrayLike ? Fn : never
107
+ type FnWhenElementOrArrayLike<ActualT, FnElement, FnArray = FnElement, FnMultiRemoteElement = FnElement, FnMultiRemoteElements = FnArray> = ActualT extends WebdriverIO.MultiRemoteElement[] ? FnMultiRemoteElements : ActualT extends WebdriverIO.MultiRemoteElement ? FnMultiRemoteElement : ActualT extends MaybeSomeElementArrayLike ? FnArray : ActualT extends ElementLike ? FnElement : never
108
+ type FnWhenElementArrayLike<ActualT, Fn, FnMultiRemoteElements = Fn> = ActualT extends WebdriverIO.MultiRemoteElement[] ? FnMultiRemoteElements : ActualT extends MaybeSomeElementArrayLike ? Fn : never
94
109
 
95
110
  /**
96
111
  * 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
97
112
  */
98
- type FnWhenMock<ActualT, Fn> = ActualT extends MockPromise | WebdriverIO.Mock ? Fn : never
113
+ type FnWhenMock<ActualT, Fn> = ActualT extends MockPromise | WebdriverIO.Mock | MultiRemoteMocks ? Fn : never
99
114
 
100
115
  interface WdioCustomAsymmetricMatchers {
101
116
  oneOf(...values: Array<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | null>): ExpectWebdriverIO.OneOfPartialMatcher<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | null>
117
+
118
+ /**
119
+ * One expected value per multi-remote instance, keyed by instance name. Every instance must be listed.
120
+ * Required for per-instance values of number matchers (`toHaveWidth`, `toHaveHeight`, `toHaveChildren`, `toBeElementsArrayOfSize`)
121
+ * and of matchers whose expected value is itself an object (`toHaveStyle`, `toHaveSize`, `toHaveElementProperty`),
122
+ * and the explicit form of the plain object shorthand for the other matchers.
123
+ *
124
+ * @example
125
+ * await expect(multiRemoteBrowser).toHaveTitle(expect.multiRemote({ chrome: 'Title', firefox: 'Titre' }))
126
+ * await expect(multiRemoteBrowser.$('h1')).toHaveStyle(expect.multiRemote({ chrome: { color: 'red' }, firefox: { color: 'blue' } }))
127
+ */
128
+ multiRemote<T>(values: MultiRemoteValues<T>): ExpectWebdriverIO.MultiRemotePartialMatcher<T>
102
129
  }
103
130
 
104
131
  /**
105
- * Matchers dedicated to Wdio Browser.
132
+ * Matchers dedicated to Wdio Browser or multi-remote Browser.
106
133
  * When asserting on a browser's properties requiring to be awaited, the return type is a Promise.
107
134
  * When actual is not a browser, the return type is never, so the function cannot be used.
108
135
  */
109
136
  interface WdioBrowserMatchers<_R, ActualT>{
110
137
  /**
111
- * `WebdriverIO.Browser` -> `getUrl`
138
+ * Browser`s url
112
139
  */
113
- toHaveUrl: FnWhenBrowser<ActualT, (url: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>, options?: ExpectWebdriverIO.StringOptions) => Promise<void>>
140
+ toHaveUrl: FnWhenBrowserOrMultiRemote<ActualT,
141
+ /**
142
+ * `WebdriverIO.Browser` -> `getUrl`
143
+ */
144
+ (
145
+ url: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
146
+ options?: ExpectWebdriverIO.StringOptions
147
+ ) => Promise<void>,
148
+
149
+ /**
150
+ * `WebdriverIO.MultiRemoteBrowser` -> `getUrl`
151
+ */
152
+ (
153
+ url: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
154
+ options?: ExpectWebdriverIO.StringOptions
155
+ ) => Promise<void>
156
+ >
114
157
 
115
158
  /**
116
- * `WebdriverIO.Browser` -> `getTitle`
159
+ * Browser`s title
117
160
  */
118
- toHaveTitle: FnWhenBrowser<ActualT, (title: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>, options?: ExpectWebdriverIO.StringOptions) => Promise<void>>
161
+ toHaveTitle: FnWhenBrowserOrMultiRemote<ActualT,
162
+ /**
163
+ * `WebdriverIO.Browser` -> `getTitle`
164
+ */
165
+ (
166
+ title: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>,
167
+ options?: ExpectWebdriverIO.StringOptions
168
+ ) => Promise<void>,
169
+
170
+ /**
171
+ * `WebdriverIO.MultiRemoteBrowser` -> `getTitle`
172
+ */
173
+ (
174
+ title: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
175
+ options?: ExpectWebdriverIO.StringOptions
176
+ ) => Promise<void>
177
+ >
119
178
 
120
179
  /**
121
180
  * `WebdriverIO.Browser` -> `execute`
122
181
  */
123
- toHaveClipboardText: FnWhenBrowser<ActualT, (clipboardText: string | RegExp | ExpectWebdriverIO.PartialMatcher<string>, options?: ExpectWebdriverIO.StringOptions) => Promise<void>>
182
+ toHaveClipboardText: FnWhenBrowserOrMultiRemote<ActualT,
183
+ /**
184
+ * `WebdriverIO.Browser` -> `getClipboard`
185
+ */
186
+ (
187
+ clipboardText: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
188
+ options?: ExpectWebdriverIO.StringOptions
189
+ ) => Promise<void>,
190
+
191
+ /**
192
+ * `WebdriverIO.MultiRemoteBrowser` -> `getClipboard`
193
+ */
194
+ (
195
+ clipboardText: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything>,
196
+ options?: ExpectWebdriverIO.StringOptions
197
+ ) => Promise<void>
198
+ >
124
199
 
125
200
  /**
126
201
  * `WebdriverIO.Browser` -> `execute`
127
202
  */
128
- toHaveLocalStorageItem: FnWhenBrowser<ActualT, {
203
+ toHaveLocalStorageItem: FnWhenBrowserOrMultiRemote<ActualT,
129
204
  /**
130
- * @deprecated since v6.0.0, removed in v8.0.0. Use `expect.anything()` instead of `undefined` as expected value.
131
- */
132
- (
133
- key: string,
134
- expectedValue: undefined,
135
- options?: ExpectWebdriverIO.StringOptions
136
- ): Promise<void>,
205
+ * `WebdriverIO.Browser` -> `getLocalStorageItem`
206
+ */
207
+ {
208
+ /**
209
+ * @deprecated since v6.0.0, removed in v8.0.0. Use `expect.anything()` instead of `undefined` as expected value.
210
+ */
211
+ (
212
+ key: string,
213
+ expectedValue: undefined,
214
+ options?: ExpectWebdriverIO.StringOptions
215
+ ): Promise<void>,
216
+
217
+ (
218
+ key: string,
219
+ expectedValue?: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything>,
220
+ options?: ExpectWebdriverIO.StringOptions
221
+ ) : Promise<void>
222
+ },
137
223
 
224
+ /**
225
+ * `WebdriverIO.MultiRemoteBrowser` -> `getLocalStorageItem`
226
+ */
138
227
  (
139
228
  key: string,
140
- expectedValue?: string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything,
229
+ expectedValue?: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything>,
141
230
  options?: ExpectWebdriverIO.StringOptions
142
- ) : Promise<void>
143
- }
231
+ ) => Promise<void>
144
232
  >
145
233
  }
146
234
 
@@ -151,12 +239,14 @@ interface WdioBrowserMatchers<_R, ActualT>{
151
239
  */
152
240
  interface WdioNetworkMatchers<_R, ActualT> {
153
241
  /**
154
- * Check that `WebdriverIO.Mock` was called
242
+ * Check that `WebdriverIO.Mock` was called.
243
+ * With multi-remote mocks (`multiRemoteBrowser.mock()`), every instance's mock must be called.
155
244
  */
156
245
  toBeRequested: FnWhenMock<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
157
246
 
158
247
  /**
159
- * Check that `WebdriverIO.Mock` was called N times
248
+ * Check that `WebdriverIO.Mock` was called N times.
249
+ * With multi-remote mocks (`multiRemoteBrowser.mock()`), every instance's mock must be called N times.
160
250
  */
161
251
  toBeRequestedTimes: FnWhenMock<ActualT, {
162
252
  (
@@ -175,18 +265,20 @@ interface WdioNetworkMatchers<_R, ActualT> {
175
265
  }>
176
266
 
177
267
  /**
178
- * Check that `WebdriverIO.Mock` was called with the specific parameters
268
+ * Check that `WebdriverIO.Mock` was called with the specific parameters.
269
+ * With multi-remote mocks (`multiRemoteBrowser.mock()`), every instance's mock must have such a call.
179
270
  */
180
271
  toBeRequestedWith: FnWhenMock<ActualT, (requestedWith: ExpectWebdriverIO.RequestedWith, options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
181
272
  }
182
273
 
183
274
  /**
184
- * Matchers dedicated to WebdriverIO Element or ElementArray (or chainable).
275
+ * Matchers dedicated to WebdriverIO Element or ElementArray (or chainable) on Browser
276
+ * For Multi-Remote Browser, MultiRemoteElement or MultiRemoteElement[]
185
277
  * When asserting on an element or element array's properties requiring to be awaited, the return type is a Promise.
186
278
  * When actual is neither of WebdriverIO.Element, WebdriverIO.ElementArray, ChainableElement, ChainableElementArray, the return type is never, so the function cannot be used.
187
279
  */
188
280
  interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
189
- // ===== $ or $$ =====
281
+ // ===== $ or $$ with Browser or Multi-Remote Browser=====
190
282
  /**
191
283
  * `WebdriverIO.Element` -> `isDisplayed`
192
284
  */
@@ -286,6 +378,26 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
286
378
  value: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything>,
287
379
  options?: ExpectWebdriverIO.StringOptions
288
380
  ): Promise<void>;
381
+ }, {
382
+ /** Element MultiRemoteBrowser.$() API */
383
+ (
384
+ attribute: string
385
+ ): Promise<void>
386
+ (
387
+ attribute: string,
388
+ value: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything>,
389
+ options?: ExpectWebdriverIO.StringOptions
390
+ ): Promise<void>
391
+ }, {
392
+ /** Elements MultiRemoteBrowser.$$() API */
393
+ (
394
+ attribute: string
395
+ ): Promise<void>
396
+ (
397
+ attribute: string,
398
+ value: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything>,
399
+ options?: ExpectWebdriverIO.StringOptions
400
+ ): Promise<void>
289
401
  }
290
402
  >
291
403
 
@@ -341,6 +453,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
341
453
  className: MaybeArray<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
342
454
  options?: ExpectWebdriverIO.StringOptions
343
455
  ) :Promise<void>
456
+ }, {
457
+ /** Element MultiRemoteBrowser.$() API */
458
+ (
459
+ className: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
460
+ options?: ExpectWebdriverIO.StringOptions
461
+ ): Promise<void>
462
+ }, {
463
+ /** Elements MultiRemoteBrowser.$$() API */
464
+ (
465
+ className: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
466
+ options?: ExpectWebdriverIO.StringOptions
467
+ ): Promise<void>
344
468
  }>
345
469
 
346
470
  toHaveElementProperty: FnWhenElementOrArrayLike<ActualT, {
@@ -396,15 +520,37 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
396
520
  value: MaybeArrayOrOneOf<string | number | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything | null>,
397
521
  options?: ExpectWebdriverIO.StringOptions
398
522
  ): Promise<void>;
523
+ }, {
524
+ /** Element MultiRemoteBrowser.$() API */
525
+ (
526
+ property: string
527
+ ): Promise<void>
528
+ (
529
+ property: string,
530
+ value: SingleOrMultiRemoteMatcher<MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything> | number>,
531
+ options?: ExpectWebdriverIO.StringOptions
532
+ ): Promise<void>
533
+ }, {
534
+ /** Elements MultiRemoteBrowser.$$() API */
535
+ (
536
+ property: string
537
+ ): Promise<void>
538
+ (
539
+ property: string,
540
+ value: MaybeArrayOrOneOf<string | number | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything | null> | ExpectWebdriverIO.MultiRemotePartialMatcher<MaybeArrayOrOneOf<string | number | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.PartialMatcherAnything | null>>,
541
+ options?: ExpectWebdriverIO.StringOptions
542
+ ): Promise<void>
399
543
  }>
400
544
 
401
545
  /**
402
546
  * `WebdriverIO.Element` -> `getProperty` value
403
547
  */
404
548
  toHaveValue: FnWhenElementOrArrayLike<ActualT,
549
+ /**
550
+ * Element(s) API
551
+ */
405
552
  /** Element $() API */
406
553
  (
407
-
408
554
  value: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
409
555
  options?: ExpectWebdriverIO.StringOptions
410
556
  ) => Promise<void>,
@@ -414,6 +560,22 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
414
560
 
415
561
  value: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
416
562
  options?: ExpectWebdriverIO.StringOptions
563
+ ) => Promise<void>,
564
+
565
+ /**
566
+ * Multi-Remote Elements API
567
+ */
568
+ /** $() API */
569
+ (
570
+ value: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
571
+ options?: ExpectWebdriverIO.StringOptions
572
+ ) => Promise<void>,
573
+
574
+ /** $$() API */
575
+ (
576
+
577
+ value: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
578
+ options?: ExpectWebdriverIO.StringOptions
417
579
  ) => Promise<void>
418
580
  >
419
581
 
@@ -480,6 +642,20 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
480
642
  expectedValue: MaybeArray<number | ExpectWebdriverIO.NumberMatcher>,
481
643
  options?: ExpectWebdriverIO.CommandOptions
482
644
  ): Promise<void>;
645
+ }, {
646
+ /** Element MultiRemoteBrowser.$() API */
647
+ (): Promise<void>
648
+ (
649
+ expectedValue: SingleOrMultiRemoteMatcher<number | ExpectWebdriverIO.NumberMatcher>,
650
+ options?: ExpectWebdriverIO.CommandOptions
651
+ ): Promise<void>
652
+ }, {
653
+ /** Elements MultiRemoteBrowser.$$() API */
654
+ (): Promise<void>
655
+ (
656
+ expectedValue: MaybeArrayOrMultiRemoteMatcher<number | ExpectWebdriverIO.NumberMatcher>,
657
+ options?: ExpectWebdriverIO.CommandOptions
658
+ ): Promise<void>
483
659
  }>
484
660
 
485
661
  /**
@@ -497,6 +673,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
497
673
  href: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
498
674
  options?: ExpectWebdriverIO.StringOptions
499
675
  ) : Promise<void>
676
+ }, {
677
+ /** Element MultiRemoteBrowser.$() API */
678
+ (
679
+ href: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
680
+ options?: ExpectWebdriverIO.StringOptions
681
+ ): Promise<void>
682
+ }, {
683
+ /** Elements MultiRemoteBrowser.$$() API */
684
+ (
685
+ href: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
686
+ options?: ExpectWebdriverIO.StringOptions
687
+ ): Promise<void>
500
688
  }>
501
689
 
502
690
  /**
@@ -514,6 +702,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
514
702
  href: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
515
703
  options?: ExpectWebdriverIO.StringOptions
516
704
  ) : Promise<void>
705
+ }, {
706
+ /** Element MultiRemoteBrowser.$() API */
707
+ (
708
+ href: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
709
+ options?: ExpectWebdriverIO.StringOptions
710
+ ): Promise<void>
711
+ }, {
712
+ /** Elements MultiRemoteBrowser.$$() API */
713
+ (
714
+ href: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
715
+ options?: ExpectWebdriverIO.StringOptions
716
+ ): Promise<void>
517
717
  }>
518
718
 
519
719
  /**
@@ -530,6 +730,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
530
730
  (
531
731
  id: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
532
732
  options?: ExpectWebdriverIO.StringOptions
733
+ ) => Promise<void>,
734
+
735
+ /** Element MultiRemoteBrowser.$() API */
736
+ (
737
+ id: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
738
+ options?: ExpectWebdriverIO.StringOptions
739
+ ) => Promise<void>,
740
+
741
+ /** Elements MultiRemoteBrowser.$$() API */
742
+ (
743
+ id: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
744
+ options?: ExpectWebdriverIO.StringOptions
533
745
  ) => Promise<void>
534
746
  >
535
747
 
@@ -554,7 +766,7 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
554
766
  * ```
555
767
  */
556
768
  toHaveText: FnWhenElementOrArrayLike<ActualT, {
557
- /** Element $() API */
769
+ /** Element browser.$() API */
558
770
  (
559
771
  text: MaybeOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
560
772
  options?: ExpectWebdriverIO.StringOptions
@@ -565,12 +777,25 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
565
777
  options?: ExpectWebdriverIO.StringOptions
566
778
  ) : Promise<void>
567
779
  }, {
568
- /** Elements $$() API */
780
+ /** Elements browser.$$() API */
569
781
  (
570
782
  text: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
571
783
  options?: ExpectWebdriverIO.StringOptions
572
784
  ) : Promise<void>
573
- }>
785
+ }, {
786
+ /** Element MultiRemoteBrowser.$() API */
787
+ (
788
+ text: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
789
+ options?: ExpectWebdriverIO.StringOptions
790
+ ) : Promise<void>
791
+ }, {
792
+ /** Elements MultiRemoteBrowser.$$() API */
793
+ (
794
+ text: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
795
+ options?: ExpectWebdriverIO.StringOptions
796
+ ) : Promise<void>
797
+ }
798
+ >
574
799
 
575
800
  /**
576
801
  * `WebdriverIO.Element` -> `getHTML`
@@ -593,6 +818,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
593
818
  text: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string> | ExpectWebdriverIO.OneOfPartialMatcher<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>>,
594
819
  options?: ExpectWebdriverIO.HTMLOptions
595
820
  ): Promise<void>
821
+ }, {
822
+ /** Element MultiRemoteBrowser.$() API */
823
+ (
824
+ text: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
825
+ options?: ExpectWebdriverIO.HTMLOptions
826
+ ): Promise<void>
827
+ }, {
828
+ /** Elements MultiRemoteBrowser.$$() API */
829
+ (
830
+ text: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
831
+ options?: ExpectWebdriverIO.HTMLOptions
832
+ ): Promise<void>
596
833
  }>
597
834
 
598
835
  /**
@@ -617,6 +854,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
617
854
  computedLabel: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
618
855
  options?: ExpectWebdriverIO.StringOptions
619
856
  ) : Promise<void>
857
+ }, {
858
+ /** Element MultiRemoteBrowser.$() API */
859
+ (
860
+ computedLabel: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
861
+ options?: ExpectWebdriverIO.StringOptions
862
+ ): Promise<void>
863
+ }, {
864
+ /** Elements MultiRemoteBrowser.$$() API */
865
+ (
866
+ computedLabel: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
867
+ options?: ExpectWebdriverIO.StringOptions
868
+ ): Promise<void>
620
869
  }>
621
870
 
622
871
  /**
@@ -641,6 +890,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
641
890
  computedRole: MaybeArrayOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
642
891
  options?: ExpectWebdriverIO.StringOptions
643
892
  ) : Promise<void>
893
+ }, {
894
+ /** Element MultiRemoteBrowser.$() API */
895
+ (
896
+ computedRole: MultiRemoteValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
897
+ options?: ExpectWebdriverIO.StringOptions
898
+ ): Promise<void>
899
+ }, {
900
+ /** Elements MultiRemoteBrowser.$$() API */
901
+ (
902
+ computedRole: MaybeArrayOrMultiRemoteWithArrayValuesOrOneOf<string | RegExp | ExpectWebdriverIO.PartialMatcher<string>>,
903
+ options?: ExpectWebdriverIO.StringOptions
904
+ ): Promise<void>
644
905
  }>
645
906
 
646
907
  /**
@@ -667,6 +928,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
667
928
  width: MaybeArray<number | ExpectWebdriverIO.NumberMatcher>,
668
929
  options?: ExpectWebdriverIO.CommandOptions
669
930
  ) : Promise<void>
931
+ }, {
932
+ /** Element MultiRemoteBrowser.$() API */
933
+ (
934
+ width: SingleOrMultiRemoteMatcher<number | ExpectWebdriverIO.NumberMatcher>,
935
+ options?: ExpectWebdriverIO.CommandOptions
936
+ ): Promise<void>
937
+ }, {
938
+ /** Elements MultiRemoteBrowser.$$() API */
939
+ (
940
+ width: MaybeArrayOrMultiRemoteMatcher<number | ExpectWebdriverIO.NumberMatcher>,
941
+ options?: ExpectWebdriverIO.CommandOptions
942
+ ): Promise<void>
670
943
  }>
671
944
 
672
945
  /**
@@ -701,6 +974,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
701
974
  height: MaybeArray<number | ExpectWebdriverIO.NumberMatcher>,
702
975
  options?: ExpectWebdriverIO.CommandOptions
703
976
  ) : Promise<void>
977
+ }, {
978
+ /** Element MultiRemoteBrowser.$() API */
979
+ (
980
+ height: SingleOrMultiRemoteMatcher<number | ExpectWebdriverIO.NumberMatcher>,
981
+ options?: ExpectWebdriverIO.CommandOptions
982
+ ): Promise<void>
983
+ }, {
984
+ /** Elements MultiRemoteBrowser.$$() API */
985
+ (
986
+ height: MaybeArrayOrMultiRemoteMatcher<number | ExpectWebdriverIO.NumberMatcher>,
987
+ options?: ExpectWebdriverIO.CommandOptions
988
+ ): Promise<void>
704
989
  }>
705
990
 
706
991
  /**
@@ -720,6 +1005,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
720
1005
  size: MaybeArray<{ height: number; width: number }>,
721
1006
  options?: ExpectWebdriverIO.CommandOptions
722
1007
  ) : Promise<void>
1008
+ }, {
1009
+ /** Element MultiRemoteBrowser.$() API */
1010
+ (
1011
+ size: SingleOrMultiRemoteMatcher<{ height: number; width: number }>,
1012
+ options?: ExpectWebdriverIO.CommandOptions
1013
+ ): Promise<void>
1014
+ }, {
1015
+ /** Elements MultiRemoteBrowser.$$() API */
1016
+ (
1017
+ size: MaybeArrayOrMultiRemoteMatcher<{ height: number; width: number }>,
1018
+ options?: ExpectWebdriverIO.CommandOptions
1019
+ ): Promise<void>
723
1020
  }>
724
1021
 
725
1022
  /**
@@ -737,6 +1034,18 @@ interface WdioElementOrArrayMatchers<_R, ActualT = unknown> {
737
1034
  style: MaybeArray<{ [key: string]: string }>,
738
1035
  options?: ExpectWebdriverIO.StringOptions
739
1036
  ) : Promise<void>
1037
+ }, {
1038
+ /** Element MultiRemoteBrowser.$() API */
1039
+ (
1040
+ style: SingleOrMultiRemoteMatcher<{ [key: string]: string }>,
1041
+ options?: ExpectWebdriverIO.StringOptions
1042
+ ): Promise<void>
1043
+ }, {
1044
+ /** Elements MultiRemoteBrowser.$$() API */
1045
+ (
1046
+ style: MaybeArrayOrMultiRemoteMatcher<{ [key: string]: string }>,
1047
+ options?: ExpectWebdriverIO.StringOptions
1048
+ ): Promise<void>
740
1049
  }>
741
1050
  }
742
1051
 
@@ -765,6 +1074,15 @@ interface WdioElementArrayOnlyMatchers<_R, ActualT = unknown> {
765
1074
  size: ExpectWebdriverIO.NumberOptions,
766
1075
  options?: ExpectWebdriverIO.CommandOptions
767
1076
  ): Promise<void>,
1077
+ }, {
1078
+ /**
1079
+ * Elements MultiRemoteBrowser.$$() API: the size is checked per browser instance.
1080
+ * A single size applies to every instance, or pass one size per instance, e.g. `expect.multiRemote({ chrome: 2, firefox: { gte: 1 } })`.
1081
+ */
1082
+ (
1083
+ size: SingleOrMultiRemoteMatcher<number | ExpectWebdriverIO.NumberMatcher>,
1084
+ options?: ExpectWebdriverIO.CommandOptions
1085
+ ): Promise<void>,
768
1086
  }>
769
1087
  }
770
1088
 
@@ -779,15 +1097,17 @@ interface WdioElementArrayOnlyMatchers<_R, ActualT = unknown> {
779
1097
  interface WdioJestOverloadedMatchers<R, ActualT> {
780
1098
  /**
781
1099
  * snapshot matcher
1100
+ * A plain `Element[]` or `MultiRemoteElement[]` is only recognized from its elements, so an empty one is snapshotted synchronously
782
1101
  * @param label optional snapshot label
783
1102
  */
784
- toMatchSnapshot(label?: string): ActualT extends WdioElementOrPromiseLike ? Promise<void> : R
1103
+ toMatchSnapshot(label?: string): ActualT extends WdioElementOrPromiseLike | WebdriverIO.MultiRemoteElement | WebdriverIO.ElementArray ? Promise<void> : ActualT extends WebdriverIO.Element[] | WebdriverIO.MultiRemoteElement[] ? Promise<void> | R : R
785
1104
  /**
786
1105
  * inline snapshot matcher
1106
+ * A plain `Element[]` or `MultiRemoteElement[]` is only recognized from its elements, so an empty one is snapshotted synchronously
787
1107
  * @param snapshot snapshot string (autogenerated if not specified)
788
1108
  * @param label optional snapshot label
789
1109
  */
790
- toMatchInlineSnapshot(snapshot?: string, label?: string): ActualT extends WdioElementOrPromiseLike ? Promise<void> : R
1110
+ toMatchInlineSnapshot(snapshot?: string, label?: string): ActualT extends WdioElementOrPromiseLike | WebdriverIO.MultiRemoteElement | WebdriverIO.ElementArray ? Promise<void> : ActualT extends WebdriverIO.Element[] | WebdriverIO.MultiRemoteElement[] ? Promise<void> | R : R
791
1111
  }
792
1112
 
793
1113
  /**
@@ -916,6 +1236,17 @@ declare namespace ExpectWebdriverIO {
916
1236
  /** @deprecated since v6.0.0, use getDefaultOptions instead, will be removed in v8.0.0 */
917
1237
  function getConfig(): DefaultOptions
918
1238
 
1239
+ /**
1240
+ * The this context available inside each matcher function.
1241
+ */
1242
+ interface MatcherContext /* extends ExpectLibMatcherContext */ {
1243
+ verb?: string
1244
+ expectation?: string
1245
+ isNot?: boolean
1246
+ isMultiRemote?: boolean
1247
+ matcherName?: keyof Matchers<void, unknown>
1248
+ }
1249
+
919
1250
  /**
920
1251
  * The below block are overloaded types from the expect library.
921
1252
  * They are required to show "everything" under the `ExpectWebdriverIO` namespace.
@@ -954,7 +1285,7 @@ declare namespace ExpectWebdriverIO {
954
1285
 
955
1286
  interface AsymmetricMatchers extends WdioAsymmetricMatchers, WdioCustomAsymmetricMatchers {}
956
1287
 
957
- interface InverseAsymmetricMatchers extends Omit<ExpectWebdriverIO.AsymmetricMatchers, 'anything' | 'any' | 'oneOf'> {}
1288
+ interface InverseAsymmetricMatchers extends Omit<ExpectWebdriverIO.AsymmetricMatchers, 'anything' | 'any' | 'oneOf' | 'multiRemote'> {}
958
1289
 
959
1290
  /**
960
1291
  * End of block overloading types from the expect library.
@@ -1065,11 +1396,12 @@ declare namespace ExpectWebdriverIO {
1065
1396
 
1066
1397
  interface FeatureFlags {
1067
1398
  /**
1068
- * Feature flag to enable the new multi-elements comparison for `toHaveText` matcher, allowing to keep the current behavior without breaking changes.
1069
- * 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.
1070
- *
1071
- * Will be removed in v6.0.0, as the new behavior will become the default and only behavior for `toHaveText` matcher.
1072
- */
1399
+ * Feature flag to enable the new multi-elements comparison for `toHaveText` matcher, allowing to keep the current behavior without breaking changes.
1400
+ * 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.
1401
+ * Also required for `some()`, `expect.oneOf()` in an expected array, and multi-remote elements with `toHaveText`.
1402
+ *
1403
+ * The new behavior is planned to become the default in the next major version.
1404
+ */
1073
1405
  useToHaveTextStrictMultiElementsCompareStrategy?: boolean
1074
1406
  }
1075
1407
 
@@ -1269,6 +1601,11 @@ declare namespace ExpectWebdriverIO {
1269
1601
  * Allow to match one of the specified value.
1270
1602
  */
1271
1603
  type OneOfPartialMatcher<T> = ExpectWebdriverIO.PartialMatcher<T[]>
1604
+
1605
+ /**
1606
+ * One expected value per multi-remote instance, see `expect.multiRemote()`.
1607
+ */
1608
+ type MultiRemotePartialMatcher<T> = ExpectWebdriverIO.PartialMatcher<MultiRemoteValues<T>>
1272
1609
  }
1273
1610
 
1274
1611
  declare module 'expect-webdriverio' {
@@ -1292,4 +1629,12 @@ declare module 'expect-webdriverio/api' {
1292
1629
  export function some<T extends ElementArrayLike>(
1293
1630
  elements: T
1294
1631
  ): WdioSome<T>
1632
+
1633
+ /**
1634
+ * One expected value per multi-remote instance, keyed by instance name. Same as `expect.multiRemote()`.
1635
+ *
1636
+ * @example
1637
+ * await expect(multiRemoteBrowser.$('h1')).toHaveStyle(multiRemote({ chrome: { color: 'red' }, firefox: { color: 'blue' } }))
1638
+ */
1639
+ export function multiRemote<T>(values: MultiRemoteValues<T>): ExpectWebdriverIO.MultiRemotePartialMatcher<T>
1295
1640
  }