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 ExpectDefaultOptions {
|
21 | |
22 |
|
23 |
|
24 | polling?: ExpectPolling | undefined;
|
25 |
|
26 | |
27 |
|
28 |
|
29 | timeout?: number | undefined;
|
30 | }
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | interface ExpectTimingActions extends ExpectDefaultOptions {
|
36 | |
37 |
|
38 |
|
39 | delay?: number | undefined;
|
40 | }
|
41 |
|
42 | interface ExpectToClickOptions extends ExpectTimingActions {
|
43 | |
44 |
|
45 |
|
46 | button?: "left" | "right" | "middle" | undefined;
|
47 |
|
48 | |
49 |
|
50 |
|
51 | clickCount?: number | undefined;
|
52 |
|
53 | |
54 |
|
55 |
|
56 | delay?: number | undefined;
|
57 |
|
58 | |
59 |
|
60 |
|
61 | text?: string | RegExp | undefined;
|
62 |
|
63 | |
64 |
|
65 |
|
66 | visible?: boolean | undefined;
|
67 | }
|
68 |
|
69 | interface ExpectPuppeteer {
|
70 |
|
71 |
|
72 | toClick(selector: string, options?: ExpectToClickOptions): Promise<void>;
|
73 | toDisplayDialog(block: () => Promise<void>): Promise<Dialog>;
|
74 | toFill(selector: string, value: string, options?: ExpectTimingActions): Promise<void>;
|
75 | toMatch(selector: string, options?: ExpectTimingActions): Promise<void>;
|
76 | toMatchElement(selector: string, options?: ExpectToClickOptions): Promise<void>;
|
77 | toSelect(selector: string, valueOrText: string, options?: ExpectTimingActions): Promise<void>;
|
78 | toUploadFile(selector: string, filePath: string, options?: ExpectTimingActions): Promise<void>;
|
79 | }
|
80 |
|
81 | declare global {
|
82 | namespace jest {
|
83 | interface Matchers<R, T> {
|
84 |
|
85 |
|
86 | toClick(selector: string, options?: ExpectToClickOptions): Promise<void>;
|
87 | toDisplayDialog(block: () => Promise<void>): Promise<Dialog>;
|
88 | toFill(selector: string, value: string, options?: ExpectTimingActions): Promise<void>;
|
89 | toFillForm(selector: string, value: { [key: string]: any}, options?: ExpectTimingActions): Promise<void>;
|
90 | toMatch(matcher: string | RegExp, options?: ExpectTimingActions): Promise<void>;
|
91 | toMatchElement(selector: string, options?: ExpectToClickOptions): Promise<ElementHandle>;
|
92 | toSelect(selector: string, valueOrText: string, options?: ExpectTimingActions): Promise<void>;
|
93 | toUploadFile(selector: string, filePath: string, options?: ExpectTimingActions): Promise<void>;
|
94 | }
|
95 | }
|
96 | }
|
97 |
|
98 | declare function expectPuppeteer(instance: ElementHandle | Page): ExpectPuppeteer;
|
99 |
|
100 | declare namespace expectPuppeteer {
|
101 | function setDefaultOptions(options: ExpectDefaultOptions): void;
|
102 | function getDefaultOptions(): ExpectDefaultOptions;
|
103 | }
|
104 |
|
105 | export = expectPuppeteer;
|