This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
global.d.ts
215 lines (210 loc) · 6.65 KB
/
global.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// copied into our codebase for autocompletion purposes from 'playwright/types/types.d.ts' so we don't depend on it.
interface PageWaitForSelectorOptions {
/**
* Defaults to `'visible'`. Can be either:
* - `'attached'` - wait for element to be present in DOM.
* - `'detached'` - wait for element to not be present in DOM.
* - `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without
* any content or with `display:none` has an empty bounding box and is not considered visible.
* - `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`.
* This is opposite to the `'visible'` option.
*/
state?: "attached" | "detached" | "visible" | "hidden"
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
* using the
* [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods.
*/
timeout?: number
}
export interface PlaywrightMatchers<R> {
/**
* Will check if the element on the page determined by the selector is checked.
*/
toBeChecked(
selector: string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if the element is checked.
*/
toBeChecked(options?: PageWaitForSelectorOptions): Promise<R>
/**
* Will check if the element on the page determined by the selector is disabled.
*/
toBeDisabled(
selector: string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if the element is disabled.
*/
toBeDisabled(options?: PageWaitForSelectorOptions): Promise<R>
/**
* Will check if the element on the page determined by the selector is enabled.
*/
toBeEnabled(
selector: string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if the element is enabled.
*/
toBeEnabled(options?: PageWaitForSelectorOptions): Promise<R>
/**
* Will check if the element's textContent on the page determined by the selector includes the given text.
* @deprecated Use toMatchText instead
*/
toHaveText(
selector: string,
value: string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if the element's value includes the given text.
* @deprecated Use toMatchText instead
*/
toHaveText(value: string, options?: PageWaitForSelectorOptions): Promise<R>
/**
* Will check if an element's attribute on the page determined by the selector matches the given pattern.
*/
toMatchAttribute(
selector: string,
attribute: string,
value: RegExp | string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if an element's attribute matches the given pattern.
*/
toMatchAttribute(
attribute: string,
value: RegExp | string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if an element's computed style property on the page determined by the selector matches the given string.
*/
toMatchComputedStyle(
selector: string,
property: string,
value: RegExp | string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if an element's computed style property matches the given string.
*/
toMatchComputedStyle(
property: string,
value: RegExp | string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if the element's textContent on the page determined by the selector matches the given pattern.
*/
toMatchText(
selector: string,
pattern: RegExp | string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if the element's value matches the given pattern.
*/
toMatchText(
pattern: RegExp | string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check if the page title matches a given string or regex.
*/
toMatchTitle(pattern: RegExp | string): Promise<R>
/**
* Will check if the page URL matches the given pattern.
*/
toMatchURL(value: RegExp | string): Promise<R>
/**
* Will check an element's value on the page determined by the selector matches the given pattern.
*/
toMatchValue(
selector: string,
value: RegExp | string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check an element's value matches the given pattern.
*/
toMatchValue(
value: RegExp | string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will compare the element's textContent on the page determined by the selector with the given text.
* @deprecated - Use `toMatchText`
*/
toEqualText(
selector: string,
value: string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will compare the element's textContent by the given text.
* @deprecated - Use `toMatchText`
*/
toEqualText(value: string, options?: PageWaitForSelectorOptions): Promise<R>
/**
* Will ensure that the element is on the page.
*/
toHaveSelector(
selector: string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check that an element on the page determined by the selector has focus.
*/
toHaveFocus(
selector: string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will check that an element has focus.
*/
toHaveFocus(options?: PageWaitForSelectorOptions): Promise<R>
/**
* Will assert that N elements with the given selector are on the page and wait for it by default.
* If its 0 elements, then it will throw since the element can't be found.
*/
toHaveSelectorCount(
selector: string,
count: number,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will compare the element's value on the page determined by the selector with the given value.
* @deprecated - use `toMatchValue` instead
*/
toEqualValue(
selector: string,
value: string,
options?: PageWaitForSelectorOptions
): Promise<R>
/**
* Will compare element's value with the given value.
* @deprecated - use `toMatchValue` instead
*/
toEqualValue(value: string, options?: PageWaitForSelectorOptions): Promise<R>
/**
* Will assert the given URL with the page's URL
* @deprecated - use `toMatchURL` instead
*/
toEqualUrl(value: string): Promise<R>
}
declare global {
namespace jest {
interface Matchers<R> extends PlaywrightMatchers<R> {}
}
namespace PlaywrightTest {
interface Matchers<R> extends PlaywrightMatchers<R> {}
}
}
export const matchers: any