expect-webdriverio 5.6.9 → 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.
- package/README.md +16 -14
- package/jasmine-wdio-expect-async.d.ts +58 -18
- package/jasmine.d.ts +9 -16
- package/lib/constants.js +4 -0
- package/lib/index.js +30 -18
- package/lib/jasmineUtils.js +3 -2
- package/lib/matchers/asymmetrics/asymmetricsUtils.js +24 -0
- package/lib/matchers/asymmetrics/oneOf.js +51 -0
- package/lib/matchers/browser/toHaveClipboardText.js +8 -9
- package/lib/matchers/browser/toHaveLocalStorageItem.js +22 -14
- package/lib/matchers/browser/toHaveTitle.js +9 -10
- package/lib/matchers/browser/toHaveUrl.js +8 -9
- package/lib/matchers/element/toBeExisting.js +8 -3
- package/lib/matchers/element/toBeSelected.js +6 -13
- package/lib/matchers/element/toHaveAttribute.js +46 -45
- package/lib/matchers/element/toHaveChildren.js +30 -32
- package/lib/matchers/element/toHaveComputedLabel.js +21 -20
- package/lib/matchers/element/toHaveComputedRole.js +21 -20
- package/lib/matchers/element/toHaveElementClass.js +57 -0
- package/lib/matchers/element/toHaveElementProperty.js +40 -32
- package/lib/matchers/element/toHaveHTML.js +22 -23
- package/lib/matchers/element/toHaveHeight.js +23 -28
- package/lib/matchers/element/toHaveSize.js +16 -14
- package/lib/matchers/element/toHaveStyle.js +20 -14
- package/lib/matchers/element/toHaveText.js +26 -44
- package/lib/matchers/element/toHaveWidth.js +23 -28
- package/lib/matchers/elements/toBeElementsArrayOfSize.js +25 -30
- package/lib/matchers/mock/toBeRequestedTimes.js +12 -17
- package/lib/matchers/mock/toBeRequestedWith.js +13 -23
- package/lib/matchers/modifiers/some.js +15 -0
- package/lib/matchers.js +1 -1
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/util/commandOptionsUtils.js +6 -0
- package/lib/util/elementsUtil.js +74 -4
- package/lib/util/executeCommand.js +94 -6
- package/lib/util/formatMessage.js +87 -32
- package/lib/util/numberOptionsUtil.js +92 -0
- package/lib/util/refetchElements.js +30 -5
- package/lib/util/stringUtil.js +12 -0
- package/lib/util/waitUntil.js +44 -0
- package/lib/utils.js +128 -105
- package/package.json +13 -11
- package/types/expect-global.d.ts +2 -1
- package/types/expect-webdriverio.d.ts +628 -136
- 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
|
-
*
|
|
35
|
+
* Indicates that a value can be either one T or an array of T.
|
|
33
36
|
*/
|
|
34
|
-
type
|
|
35
|
-
|
|
36
|
-
type
|
|
37
|
-
type ElementArrayPromise = Promise<WebdriverIO.ElementArray>
|
|
37
|
+
type MaybeArray<T> = T | T[]
|
|
38
|
+
|
|
39
|
+
type MaybeSome<T> = T | WdioSome<T>
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
|
-
*
|
|
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.
|
|
41
45
|
*/
|
|
42
|
-
type
|
|
46
|
+
type MaybeArrayOrOneOf<T> = T | (T | ExpectWebdriverIO.OneOfPartialMatcher<Exclude<T, ExpectWebdriverIO.PartialMatcherAnything | number>>)[] | ExpectWebdriverIO.OneOfPartialMatcher<Exclude<T, ExpectWebdriverIO.PartialMatcherAnything | number>>
|
|
43
47
|
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
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.
|
|
46
51
|
*/
|
|
47
|
-
type
|
|
52
|
+
type MaybeOneOf<T> = T | ExpectWebdriverIO.OneOfPartialMatcher<Exclude<T, ExpectWebdriverIO.PartialMatcherAnything>>
|
|
48
53
|
|
|
49
54
|
/**
|
|
50
|
-
*
|
|
55
|
+
* Real Promise and wdio chainable promise types.
|
|
56
|
+
*/
|
|
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[]>
|
|
62
|
+
|
|
63
|
+
/**
|
|
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
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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,
|
|
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` -> `
|
|
208
|
+
* `WebdriverIO.Element` -> `isClickable`
|
|
155
209
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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>>
|
|
160
216
|
|
|
161
217
|
/**
|
|
218
|
+
* `WebdriverIO.Element` -> `isDisplayedInViewport`
|
|
219
|
+
*/
|
|
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
|
+
>
|
|
288
|
+
|
|
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,
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
207
|
-
options?: ExpectWebdriverIO.StringOptions,
|
|
208
|
-
) => Promise<void>
|
|
209
|
-
>
|
|
351
|
+
): Promise<void>;
|
|
210
352
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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` -> `
|
|
399
|
+
* `WebdriverIO.Element` -> `getProperty` value
|
|
236
400
|
*/
|
|
237
|
-
|
|
401
|
+
toHaveValue: FnWhenElementOrArrayLike<ActualT,
|
|
402
|
+
/** Element $() API */
|
|
403
|
+
(
|
|
238
404
|
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
|
|
246
|
-
*/
|
|
247
|
-
toBeSelected: FnWhenElementOrArrayLike<ActualT, (options?: ExpectWebdriverIO.CommandOptions) => Promise<void>>
|
|
409
|
+
/** Elements $$() API */
|
|
410
|
+
(
|
|
248
411
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
*
|
|
419
|
+
* Supports less / greater then or equals to be passed in value as a NumberMatcher.
|
|
257
420
|
*/
|
|
258
|
-
toHaveChildren: FnWhenElementOrArrayLike<ActualT,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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,
|
|
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')`
|
|
354
|
-
* Checks if the element's height equals the given number
|
|
669
|
+
* `WebdriverIO.Element` -> `getSize('height')`
|
|
670
|
+
* Checks if the element's height equals the given number.
|
|
355
671
|
*
|
|
356
|
-
* @param
|
|
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
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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,
|
|
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
|
-
*
|
|
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
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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
|
/**
|
|
@@ -468,8 +842,49 @@ type WdioAsymmetricMatchers = ExpectLibAsymmetricMatchers
|
|
|
468
842
|
type WdioAsymmetricMatcher<R> = ExpectWebdriverIO.PartialMatcher<R> & {
|
|
469
843
|
// Overwrite protected properties of expect.AsymmetricMatcher to access them
|
|
470
844
|
sample: R;
|
|
845
|
+
inverse?: boolean;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
type WdioOneOfAsymmetricMatcher<R> = ExpectWebdriverIO.PartialMatcher<R> & {
|
|
849
|
+
sample: [R];
|
|
471
850
|
}
|
|
472
851
|
|
|
852
|
+
type JasmineBaseAsymmetricMatcher = {
|
|
853
|
+
jasmineToString(): string;
|
|
854
|
+
asymmetricMatch(other: unknown): boolean;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Jasmine asymetric matcher does not always use sample, some use expected. `any` uses even `expectedObject`
|
|
859
|
+
* @see https://github.com/jasmine/jasmine/tree/v5.13.0/src/core/asymmetric_equality
|
|
860
|
+
*/
|
|
861
|
+
type JasmineAsymmetricMatcher<R> = JasmineBaseAsymmetricMatcher & ({
|
|
862
|
+
expected: R;
|
|
863
|
+
} | {
|
|
864
|
+
sample: R;
|
|
865
|
+
} | {
|
|
866
|
+
regexp: string | RegExp;
|
|
867
|
+
} | {
|
|
868
|
+
expectedObject: R;
|
|
869
|
+
} | {} // jasmine.anything()
|
|
870
|
+
)
|
|
871
|
+
|
|
872
|
+
type JasmineStringContainingAsymmetricMatcher<R> = JasmineBaseAsymmetricMatcher & {
|
|
873
|
+
expected: R;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
type JasmineStringMatchingAsymmetricMatcher<R extends string | RegExp> = JasmineBaseAsymmetricMatcher & {
|
|
877
|
+
regexp: R;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
type JasmineStringAsymmetricMatcher<R extends string | RegExp> = JasmineStringContainingAsymmetricMatcher<R> | JasmineStringMatchingAsymmetricMatcher<R>
|
|
881
|
+
|
|
882
|
+
type JasmineAnythingAsymmetricMatcher = JasmineBaseAsymmetricMatcher & {}
|
|
883
|
+
|
|
884
|
+
type AsymmetricMatcher<R> = WdioAsymmetricMatcher<R> | JasmineStringContainingAsymmetricMatcher<R> | (R extends string | RegExp ? JasmineStringMatchingAsymmetricMatcher<R> : never) | JasmineAsymmetricMatcher<R>
|
|
885
|
+
|
|
886
|
+
type WdioAnythingAsymmetricMatcher = ExpectLibAnything | JasmineAnythingAsymmetricMatcher
|
|
887
|
+
|
|
473
888
|
declare namespace ExpectWebdriverIO {
|
|
474
889
|
/**
|
|
475
890
|
* When importing expect from 'expect-webdriverio', instead of using globals this is the one used.
|
|
@@ -480,9 +895,22 @@ declare namespace ExpectWebdriverIO {
|
|
|
480
895
|
/**
|
|
481
896
|
* Used by the webdriverio main project to configure the matchers in the runner.
|
|
482
897
|
*/
|
|
898
|
+
function setDefaultOptions(options: DefaultOptions): void
|
|
899
|
+
/** @deprecated since v6.0.0, use setDefaultOptions instead, will be removed in v8.0.0 */
|
|
483
900
|
function setOptions(options: DefaultOptions): void
|
|
484
|
-
|
|
485
|
-
|
|
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
|
|
486
914
|
|
|
487
915
|
/**
|
|
488
916
|
* The below block are overloaded types from the expect library.
|
|
@@ -512,17 +940,23 @@ declare namespace ExpectWebdriverIO {
|
|
|
512
940
|
<T = unknown>(actual: T): T extends PromiseLike<unknown> ? ExpectWebdriverIO.MatchersAndInverse<void, T> & ExpectWebdriverIO.PromiseMatchers<T> : ExpectWebdriverIO.MatchersAndInverse<void, T>;
|
|
513
941
|
}
|
|
514
942
|
|
|
515
|
-
|
|
943
|
+
/**
|
|
944
|
+
* Matchers defining the custom wdio matchers.
|
|
945
|
+
* Matchers is documented as the interface to augment to add other custom matchers.
|
|
946
|
+
*
|
|
947
|
+
* We MUST NOT have Jest's expect Lib matchers here, so that we can use it with Jasmine augmentation as well.
|
|
948
|
+
*/
|
|
949
|
+
interface Matchers<R extends void | Promise<void>, T> extends WdioCustomMatchers<R, T> {}
|
|
516
950
|
|
|
517
|
-
interface AsymmetricMatchers extends WdioAsymmetricMatchers {}
|
|
951
|
+
interface AsymmetricMatchers extends WdioAsymmetricMatchers, WdioCustomAsymmetricMatchers {}
|
|
518
952
|
|
|
519
|
-
interface InverseAsymmetricMatchers extends Omit<ExpectWebdriverIO.AsymmetricMatchers, 'anything' | 'any'> {}
|
|
953
|
+
interface InverseAsymmetricMatchers extends Omit<ExpectWebdriverIO.AsymmetricMatchers, 'anything' | 'any' | 'oneOf'> {}
|
|
520
954
|
|
|
521
955
|
/**
|
|
522
956
|
* End of block overloading types from the expect library.
|
|
523
957
|
*/
|
|
524
958
|
|
|
525
|
-
type MatchersAndInverse<R extends void | Promise<void>, ActualT> = ExpectWebdriverIO.Matchers<R, ActualT> & ExpectLibInverse<ExpectWebdriverIO.Matchers<R, ActualT>>
|
|
959
|
+
type MatchersAndInverse<R extends void | Promise<void>, ActualT> = (ExpectWebdriverIO.Matchers<R, ActualT> & ExpectLibMatchers<R, ActualT>) & ExpectLibInverse<ExpectWebdriverIO.Matchers<R, ActualT> & ExpectLibMatchers<R, ActualT>>
|
|
526
960
|
|
|
527
961
|
/**
|
|
528
962
|
* Take from expect library
|
|
@@ -595,7 +1029,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
595
1029
|
const wdioCustomMatchers: MatchersObject
|
|
596
1030
|
|
|
597
1031
|
/**
|
|
598
|
-
* @deprecated use `wdioCustomMatchers` instead
|
|
1032
|
+
* @deprecated since 5.6.9 use `wdioCustomMatchers` instead, will be removed in v8.0.0?
|
|
599
1033
|
*/
|
|
600
1034
|
const matchers: Map<string, RawMatcherFn>
|
|
601
1035
|
|
|
@@ -625,6 +1059,16 @@ declare namespace ExpectWebdriverIO {
|
|
|
625
1059
|
result: AssertionResult
|
|
626
1060
|
}
|
|
627
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
|
+
|
|
628
1072
|
interface DefaultOptions {
|
|
629
1073
|
/**
|
|
630
1074
|
* time in ms to wait for expectation to succeed. Default: 3000
|
|
@@ -645,6 +1089,8 @@ declare namespace ExpectWebdriverIO {
|
|
|
645
1089
|
* hook that gets executed after each assertion, it contains the result of the assertion
|
|
646
1090
|
*/
|
|
647
1091
|
afterAssertion?: (params: AfterAssertionHookParams) => Promise<void>
|
|
1092
|
+
|
|
1093
|
+
featureFlags?: FeatureFlags
|
|
648
1094
|
}
|
|
649
1095
|
|
|
650
1096
|
interface CommandOptions extends DefaultOptions {
|
|
@@ -703,16 +1149,23 @@ declare namespace ExpectWebdriverIO {
|
|
|
703
1149
|
replace?: [string | RegExp, string | Function] | Array<[string | RegExp, string | Function]>
|
|
704
1150
|
|
|
705
1151
|
/**
|
|
706
|
-
*
|
|
1152
|
+
* convert element's property value to string
|
|
707
1153
|
*/
|
|
708
1154
|
asString?: boolean
|
|
709
1155
|
}
|
|
710
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
|
+
*/
|
|
711
1162
|
interface NumberOptions extends CommandOptions {
|
|
1163
|
+
|
|
712
1164
|
/**
|
|
713
1165
|
* equals
|
|
714
1166
|
*/
|
|
715
1167
|
eq?: number
|
|
1168
|
+
|
|
716
1169
|
/**
|
|
717
1170
|
* less than or equals
|
|
718
1171
|
*/
|
|
@@ -751,6 +1204,22 @@ declare namespace ExpectWebdriverIO {
|
|
|
751
1204
|
visibilityProperty?: boolean
|
|
752
1205
|
}
|
|
753
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
|
+
|
|
754
1223
|
type RequestedWith = {
|
|
755
1224
|
url?: string | ExpectWebdriverIO.PartialMatcher<string>| ((url: string) => boolean)
|
|
756
1225
|
method?: string | Array<string>
|
|
@@ -785,6 +1254,29 @@ declare namespace ExpectWebdriverIO {
|
|
|
785
1254
|
* Some properties are omitted for the type check to work correctly.
|
|
786
1255
|
*/
|
|
787
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>
|
|
788
1280
|
}
|
|
789
1281
|
|
|
790
1282
|
declare module 'expect-webdriverio' {
|