expect-webdriverio 4.5.2 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/constants.js +2 -0
- package/lib/matchers/browser/toHaveClipboardText.js +37 -0
- package/lib/matchers/browser/toHaveTitle.js +22 -4
- package/lib/matchers/browser/toHaveUrl.js +22 -4
- package/lib/matchers/element/toBeClickable.js +12 -2
- package/lib/matchers/element/toBeDisabled.js +12 -2
- package/lib/matchers/element/toBeDisplayed.js +11 -1
- package/lib/matchers/element/toBeDisplayedInViewport.js +12 -2
- package/lib/matchers/element/toBeEnabled.js +12 -2
- package/lib/matchers/element/toBeExisting.js +12 -2
- package/lib/matchers/element/toBeFocused.js +12 -2
- package/lib/matchers/element/toBeSelected.js +24 -4
- package/lib/matchers/element/toHaveAttribute.js +25 -9
- package/lib/matchers/element/toHaveChildren.js +17 -5
- package/lib/matchers/element/toHaveClass.js +28 -6
- package/lib/matchers/element/toHaveComputedLabel.js +23 -5
- package/lib/matchers/element/toHaveComputedRole.js +23 -5
- package/lib/matchers/element/toHaveElementProperty.js +14 -2
- package/lib/matchers/element/toHaveHTML.js +22 -4
- package/lib/matchers/element/toHaveHeight.js +17 -5
- package/lib/matchers/element/toHaveHref.js +22 -3
- package/lib/matchers/element/toHaveId.js +15 -3
- package/lib/matchers/element/toHaveSize.js +17 -5
- package/lib/matchers/element/toHaveStyle.js +16 -4
- package/lib/matchers/element/toHaveText.js +22 -4
- package/lib/matchers/element/toHaveValue.js +6 -0
- package/lib/matchers/element/toHaveWidth.js +17 -5
- package/lib/matchers/elements/toBeElementsArrayOfSize.js +18 -6
- package/lib/matchers/mock/toBeRequested.js +1 -1
- package/lib/matchers/mock/toBeRequestedTimes.js +18 -6
- package/lib/matchers/mock/toBeRequestedWith.js +23 -11
- package/lib/matchers.js +4 -14
- package/package.json +2 -1
- package/types/expect-webdriverio.d.ts +74 -5
- package/lib/matchers/browser/toHaveTitleContaining.js +0 -7
- package/lib/matchers/browser/toHaveUrlContaining.js +0 -7
- package/lib/matchers/element/toHaveAttributeContaining.js +0 -8
- package/lib/matchers/element/toHaveClassContaining.js +0 -10
- package/lib/matchers/element/toHaveComputedLabelContaining.js +0 -7
- package/lib/matchers/element/toHaveComputedRoleContaining.js +0 -7
- package/lib/matchers/element/toHaveHTMLContaining.js +0 -7
- package/lib/matchers/element/toHaveHrefContaining.js +0 -8
- package/lib/matchers/element/toHaveTextContaining.js +0 -7
- package/lib/matchers/element/toHaveValueContaining.js +0 -7
|
@@ -4,17 +4,45 @@ declare namespace ExpectWebdriverIO {
|
|
|
4
4
|
): Matchers<R, T>
|
|
5
5
|
function setOptions(options: DefaultOptions): void
|
|
6
6
|
function getConfig(): any
|
|
7
|
+
|
|
8
|
+
interface AssertionResult {
|
|
9
|
+
pass: boolean
|
|
10
|
+
message(): string
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
const matchers: Record<
|
|
8
14
|
string,
|
|
9
15
|
(
|
|
10
16
|
actual: any,
|
|
11
17
|
...expected: any[]
|
|
12
|
-
) => Promise<
|
|
13
|
-
pass: boolean
|
|
14
|
-
message(): string
|
|
15
|
-
}>
|
|
18
|
+
) => Promise<AssertionResult>
|
|
16
19
|
>
|
|
17
20
|
|
|
21
|
+
interface AssertionHookParams {
|
|
22
|
+
/**
|
|
23
|
+
* name of the matcher, e.g. `toHaveText` or `toBeClickable`
|
|
24
|
+
*/
|
|
25
|
+
matcherName: keyof Matchers<unknown, unknown>,
|
|
26
|
+
/**
|
|
27
|
+
* Value that the user has passed in
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```
|
|
31
|
+
* expect(el).toBeClickable() // expectedValue is undefined
|
|
32
|
+
* expect(el).toHaveText('foo') // expectedValue is `'foo'`
|
|
33
|
+
* expect(el).toHaveAttribute('attr', 'value', { ... }) // expectedValue is `['attr', 'value]`
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
expectedValue?: any,
|
|
37
|
+
/**
|
|
38
|
+
* Options that the user has passed in, e.g. `expect(el).toHaveText('foo', { ignoreCase: true })` -> `{ ignoreCase: true }`
|
|
39
|
+
*/
|
|
40
|
+
options: CommandOptions | HTMLOptions | StringOptions | NumberOptions
|
|
41
|
+
}
|
|
42
|
+
interface AfterAssertionHookParams extends AssertionHookParams {
|
|
43
|
+
result: AssertionResult
|
|
44
|
+
}
|
|
45
|
+
|
|
18
46
|
interface DefaultOptions {
|
|
19
47
|
/**
|
|
20
48
|
* time in ms to wait for expectation to succeed. Default: 3000
|
|
@@ -25,6 +53,16 @@ declare namespace ExpectWebdriverIO {
|
|
|
25
53
|
* interval between attempts. Default: 100
|
|
26
54
|
*/
|
|
27
55
|
interval?: number
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* hook that gets executed before each assertion
|
|
59
|
+
*/
|
|
60
|
+
beforeAssertion?: (params: AssertionHookParams) => Promise<void>
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* hook that gets executed after each assertion, it contains the result of the assertion
|
|
64
|
+
*/
|
|
65
|
+
afterAssertion?: (params: AfterAssertionHookParams) => Promise<void>
|
|
28
66
|
}
|
|
29
67
|
|
|
30
68
|
interface CommandOptions extends DefaultOptions {
|
|
@@ -141,6 +179,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
141
179
|
/**
|
|
142
180
|
* `WebdriverIO.Element` -> `getAttribute`
|
|
143
181
|
* Element's attribute includes the value.
|
|
182
|
+
* @deprecated use `expect(el).toHaveAttribute('attribute', expect.stringContaining('...'))` instead
|
|
144
183
|
*/
|
|
145
184
|
toHaveAttributeContaining(
|
|
146
185
|
attribute: string,
|
|
@@ -150,6 +189,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
150
189
|
/**
|
|
151
190
|
* `WebdriverIO.Element` -> `getAttribute`
|
|
152
191
|
* Element's attribute includes the value.
|
|
192
|
+
* @deprecated use `expect(el).toHaveAttr('attribute', expect.stringContaining('...'))` instead
|
|
153
193
|
*/
|
|
154
194
|
toHaveAttrContaining(
|
|
155
195
|
attribute: string,
|
|
@@ -170,14 +210,15 @@ declare namespace ExpectWebdriverIO {
|
|
|
170
210
|
|
|
171
211
|
/**
|
|
172
212
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
173
|
-
* @deprecated since v1.3.1 - use `toHaveElementClassContaining` instead.
|
|
174
213
|
* Element's class includes the className.
|
|
214
|
+
* @deprecated since v1.3.1 - use `toHaveElementClassContaining` instead.
|
|
175
215
|
*/
|
|
176
216
|
toHaveClassContaining(className: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
177
217
|
|
|
178
218
|
/**
|
|
179
219
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
180
220
|
* Element's class includes the className.
|
|
221
|
+
* @deprecated use `expect(el).toHaveElementClass(expect.stringContaining('...'))` instead
|
|
181
222
|
*/
|
|
182
223
|
toHaveElementClassContaining(className: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
183
224
|
|
|
@@ -197,6 +238,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
197
238
|
/**
|
|
198
239
|
* `WebdriverIO.Element` -> `getProperty` value
|
|
199
240
|
* Element's value includes the value.
|
|
241
|
+
* @deprecated use `expect(el).toHaveValue(expect.stringContaining('...'))` instead
|
|
200
242
|
*/
|
|
201
243
|
toHaveValueContaining(value: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
202
244
|
|
|
@@ -256,11 +298,13 @@ declare namespace ExpectWebdriverIO {
|
|
|
256
298
|
/**
|
|
257
299
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
258
300
|
* Element's href includes the value provided
|
|
301
|
+
* @deprecated use `expect(el).toHaveHref(expect.stringContaining('...'))` instead
|
|
259
302
|
*/
|
|
260
303
|
toHaveHrefContaining(href: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
261
304
|
/**
|
|
262
305
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
263
306
|
* Element's href includes the value provided
|
|
307
|
+
* @deprecated use `expect(el).toHaveLink(expect.stringContaining('...'))` instead
|
|
264
308
|
*/
|
|
265
309
|
toHaveLinkContaining(href: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
266
310
|
|
|
@@ -269,6 +313,11 @@ declare namespace ExpectWebdriverIO {
|
|
|
269
313
|
*/
|
|
270
314
|
toHaveId(id: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
271
315
|
|
|
316
|
+
/**
|
|
317
|
+
* `WebdriverIO.Element` -> `getSize` value
|
|
318
|
+
*/
|
|
319
|
+
toHaveSize(id: string | RegExp | ExpectWebdriverIO.PartialMatcher, size: { height: number; width: number }, options?: ExpectWebdriverIO.StringOptions): R
|
|
320
|
+
|
|
272
321
|
/**
|
|
273
322
|
* `WebdriverIO.Element` -> `getText`
|
|
274
323
|
* Element's text equals the text provided
|
|
@@ -280,6 +329,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
280
329
|
/**
|
|
281
330
|
* `WebdriverIO.Element` -> `getText`
|
|
282
331
|
* Element's text includes the text provided
|
|
332
|
+
* @deprecated use `expect(el).toHaveText(expect.stringContaining('...'))` instead
|
|
283
333
|
*/
|
|
284
334
|
toHaveTextContaining(
|
|
285
335
|
text: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
@@ -294,6 +344,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
294
344
|
/**
|
|
295
345
|
* `WebdriverIO.Element` -> `getHTML`
|
|
296
346
|
* Element's html includes the html provided
|
|
347
|
+
* @deprecated use `expect(el).toHaveHTML(expect.stringContaining('...'))` instead
|
|
297
348
|
*/
|
|
298
349
|
toHaveHTMLContaining(
|
|
299
350
|
html: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
@@ -311,6 +362,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
311
362
|
/**
|
|
312
363
|
* `WebdriverIO.Element` -> `getComputedLabel`
|
|
313
364
|
* Element's computed label includes the computed label provided
|
|
365
|
+
* @deprecated use `expect(el).toHaveComputedLabel(expect.stringContaining('...'))` instead
|
|
314
366
|
*/
|
|
315
367
|
toHaveComputedLabelContaining(
|
|
316
368
|
computedLabel: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
@@ -328,6 +380,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
328
380
|
/**
|
|
329
381
|
* `WebdriverIO.Element` -> `getComputedRole`
|
|
330
382
|
* Element's computed role includes the computed role provided
|
|
383
|
+
* @deprecated use `expect(el).toHaveComputedRole(expect.stringContaining('...'))` instead
|
|
331
384
|
*/
|
|
332
385
|
toHaveComputedRoleContaining(
|
|
333
386
|
computedRole: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
@@ -367,6 +420,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
367
420
|
/**
|
|
368
421
|
* `WebdriverIO.Browser` -> `getUrl`
|
|
369
422
|
* Browser's url includes the provided text
|
|
423
|
+
* @deprecated use `expect(el).toHaveUrl(expect.stringContaining('...'))` instead
|
|
370
424
|
*/
|
|
371
425
|
toHaveUrlContaining(url: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
372
426
|
|
|
@@ -379,9 +433,24 @@ declare namespace ExpectWebdriverIO {
|
|
|
379
433
|
/**
|
|
380
434
|
* `WebdriverIO.Browser` -> `getTitle`
|
|
381
435
|
* Browser's title includes the provided text
|
|
436
|
+
* @deprecated use `expect(el).toHaveTitle(expect.stringContaining('...'))` instead
|
|
382
437
|
*/
|
|
383
438
|
toHaveTitleContaining(title: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
384
439
|
|
|
440
|
+
/**
|
|
441
|
+
* `WebdriverIO.Browser` -> `execute`
|
|
442
|
+
*/
|
|
443
|
+
toHaveClipboardText(clipboardText: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
444
|
+
|
|
445
|
+
// ===== browser only =====
|
|
446
|
+
/**
|
|
447
|
+
* `WebdriverIO.Browser` -> `execute`
|
|
448
|
+
* Browser's clipboard includes the provided text
|
|
449
|
+
* @deprecated use `expect(el).toHaveClipboardText(expect.stringContaining('...'))` instead
|
|
450
|
+
*/
|
|
451
|
+
toHaveClipboardTextContaining(clipboardText: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
452
|
+
|
|
453
|
+
|
|
385
454
|
// ===== $$ only =====
|
|
386
455
|
/**
|
|
387
456
|
* `WebdriverIO.ElementArray` -> `$$('...').length`
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { toHaveAttributeAndValueFn } from './toHaveAttribute.js';
|
|
2
|
-
export function toHaveAttributeContaining(el, attribute, value, options = {}) {
|
|
3
|
-
return toHaveAttributeAndValueFn.call(this, el, attribute, value, {
|
|
4
|
-
...options,
|
|
5
|
-
containing: true
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
export const toHaveAttrContaining = toHaveAttributeContaining;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { toHaveAttributeAndValueFn } from './toHaveAttribute.js';
|
|
2
|
-
export function toHaveElementClassContaining(...args) {
|
|
3
|
-
return toHaveClassContaining.call(this, ...args);
|
|
4
|
-
}
|
|
5
|
-
export function toHaveClassContaining(el, className, options = {}) {
|
|
6
|
-
return toHaveAttributeAndValueFn.call(this, el, 'class', className, {
|
|
7
|
-
...options,
|
|
8
|
-
containing: true
|
|
9
|
-
});
|
|
10
|
-
}
|