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