1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import { ElementHandle, Page } from "puppeteer";
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | type ExpectPolling = number | "mutation" | "raf";
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | interface ExpectTimingActions {
|
20 | |
21 |
|
22 |
|
23 | polling?: ExpectPolling;
|
24 |
|
25 | |
26 |
|
27 |
|
28 | timeout?: number;
|
29 | }
|
30 |
|
31 | interface ExpectToClickOptions extends ExpectTimingActions {
|
32 | |
33 |
|
34 |
|
35 | text?: string | RegExp;
|
36 | }
|
37 |
|
38 | interface ExpectPuppeteer {
|
39 | toClick(selector: string, options?: ExpectToClickOptions): Promise<void>;
|
40 | toDisplayDialog(block: () => Promise<void>): Promise<void>;
|
41 | toFill(selector: string, value: string, options?: ExpectTimingActions): Promise<void>;
|
42 | toMatchElement(selector: string, value: string, options?: ExpectTimingActions): Promise<void>;
|
43 | toSelect(selector: string, valueOrText: string, options?: ExpectTimingActions): Promise<void>;
|
44 | toUploadFile(selector: string, filePath: string, options?: ExpectTimingActions): Promise<void>;
|
45 | }
|
46 |
|
47 | declare global {
|
48 | namespace jest {
|
49 |
|
50 | interface Matchers<R> extends ExpectPuppeteer { }
|
51 | }
|
52 | }
|
53 |
|
54 | declare function expectPuppeteer(instance: ElementHandle | Page): ExpectPuppeteer;
|
55 | export = expectPuppeteer;
|