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 |
|
40 |
|
41 | toClick(selector: string, options?: ExpectToClickOptions): Promise<void>;
|
42 | toDisplayDialog(block: () => Promise<void>): Promise<void>;
|
43 | toFill(selector: string, value: string, options?: ExpectTimingActions): Promise<void>;
|
44 | toMatch(selector: string, options?: ExpectTimingActions): Promise<void>;
|
45 | toMatchElement(selector: string, options?: ExpectToClickOptions): Promise<void>;
|
46 | toSelect(selector: string, valueOrText: string, options?: ExpectTimingActions): Promise<void>;
|
47 | toUploadFile(selector: string, filePath: string, options?: ExpectTimingActions): Promise<void>;
|
48 | }
|
49 |
|
50 | declare global {
|
51 | namespace jest {
|
52 |
|
53 | interface Matchers<R> {
|
54 |
|
55 |
|
56 | toClick(selector: string, options?: ExpectToClickOptions): Promise<void>;
|
57 | toDisplayDialog(block: () => Promise<void>): Promise<void>;
|
58 | toFill(selector: string, value: string, options?: ExpectTimingActions): Promise<void>;
|
59 | toMatch(selector: string, options?: ExpectTimingActions): Promise<void>;
|
60 | toMatchElement(selector: string, options?: ExpectToClickOptions): Promise<void>;
|
61 | toSelect(selector: string, valueOrText: string, options?: ExpectTimingActions): Promise<void>;
|
62 | toUploadFile(selector: string, filePath: string, options?: ExpectTimingActions): Promise<void>;
|
63 | }
|
64 | }
|
65 | }
|
66 |
|
67 | declare function expectPuppeteer(instance: ElementHandle | Page): ExpectPuppeteer;
|
68 | export = expectPuppeteer;
|