vite-plus 0.1.24 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +8 -6
  3. package/bin/oxfmt +5 -2
  4. package/bin/oxlint +12 -2
  5. package/binding/index.cjs +84 -67
  6. package/binding/index.d.cts +155 -4
  7. package/dist/{agent-Nuk-9l77.js → agent-BD31CsvU.js} +941 -70
  8. package/dist/bin.js +22 -30
  9. package/dist/{compat-DXZgnEyq.js → compat-Cql3K40m.js} +1 -1
  10. package/dist/config/bin.js +30 -14
  11. package/dist/constants-CrfJQIUX.js +66 -0
  12. package/dist/create/bin.d.ts +6 -0
  13. package/dist/create/bin.js +508 -232
  14. package/dist/define-config-2tfJoXr1.d.ts +305 -0
  15. package/dist/define-config-BGSjF6Xp.cjs +488 -0
  16. package/dist/define-config-DJUehepE.js +445 -0
  17. package/dist/define-config.cjs +8 -1
  18. package/dist/define-config.d.ts +2 -2
  19. package/dist/define-config.js +2 -2
  20. package/dist/dist-DRJUd9bL.js +3 -0
  21. package/dist/{dist-BgQuvbtq.js → dist-Oxo16Y0q.js} +4 -4
  22. package/dist/index.cjs +9 -4
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +3 -3
  25. package/dist/{main-DpJl3LoU.js → json-Dn87fvjk.js} +137 -1
  26. package/dist/migration/bin.js +292 -76
  27. package/dist/{oxlint-plugin-config-B89iKTKN.js → oxlint-plugin-config-q8a5PFch.js} +1 -1
  28. package/dist/oxlint-plugin.js +11 -3
  29. package/dist/pack-bin.js +44 -15
  30. package/dist/{package-PmBUZ-ve.js → package-BHirM1_v.js} +3 -138
  31. package/dist/{report-DgSBQUdz.js → report-BHSkWqRR.js} +2 -0
  32. package/dist/{resolve-vite-config-TTvhycU1.js → resolve-vite-config-CmdsfQzS.js} +13 -4
  33. package/dist/staged/bin.js +3 -3
  34. package/dist/test/_at-vitest-browser/context.d.ts +2 -0
  35. package/dist/test/_at-vitest-browser.d.ts +2 -0
  36. package/dist/test/browser/context.d.ts +2 -2
  37. package/dist/test/browser/context.js +1 -1
  38. package/dist/test/browser/providers/playwright/context.d.ts +1 -0
  39. package/dist/test/browser/providers/playwright/context.js +1 -0
  40. package/dist/test/browser/providers/playwright.d.ts +124 -2
  41. package/dist/test/browser/providers/playwright.js +1 -1
  42. package/dist/test/browser/providers/preview/context.d.ts +1 -0
  43. package/dist/test/browser/providers/preview/context.js +1 -0
  44. package/dist/test/browser/providers/preview.d.ts +32 -2
  45. package/dist/test/browser/providers/preview.js +1 -1
  46. package/dist/test/browser/providers/webdriverio/context.d.ts +1 -0
  47. package/dist/test/browser/providers/webdriverio/context.js +1 -0
  48. package/dist/test/browser/providers/webdriverio.d.ts +77 -2
  49. package/dist/test/browser/providers/webdriverio.js +1 -1
  50. package/dist/test/browser-compat.d.ts +2 -0
  51. package/dist/test/browser-compat.js +1 -1
  52. package/dist/test/browser-playwright/context.d.ts +1 -0
  53. package/dist/test/browser-playwright/context.js +1 -0
  54. package/dist/test/browser-playwright.d.ts +124 -2
  55. package/dist/test/browser-playwright.js +1 -1
  56. package/dist/test/browser-preview/context.d.ts +1 -0
  57. package/dist/test/browser-preview/context.js +1 -0
  58. package/dist/test/browser-preview.d.ts +32 -2
  59. package/dist/test/browser-preview.js +1 -1
  60. package/dist/test/browser-webdriverio/context.d.ts +1 -0
  61. package/dist/test/browser-webdriverio/context.js +1 -0
  62. package/dist/test/browser-webdriverio.d.ts +77 -2
  63. package/dist/test/browser-webdriverio.js +1 -1
  64. package/dist/test/browser.d.ts +2 -2
  65. package/dist/test/browser.js +1 -1
  66. package/dist/test/client.js +1 -1
  67. package/dist/test/config.cjs +1 -1
  68. package/dist/test/config.d.ts +2 -2
  69. package/dist/test/config.js +1 -1
  70. package/dist/test/context.d.ts +942 -2
  71. package/dist/test/context.js +1 -1
  72. package/dist/test/coverage.d.ts +2 -2
  73. package/dist/test/coverage.js +1 -1
  74. package/dist/test/environments.d.ts +2 -2
  75. package/dist/test/environments.js +1 -1
  76. package/dist/test/globals.d.ts +2 -2
  77. package/dist/test/import-meta.d.ts +2 -2
  78. package/dist/test/importMeta.d.ts +2 -2
  79. package/dist/test/index.cjs +1 -1
  80. package/dist/test/index.d.cts +2 -2
  81. package/dist/test/index.d.ts +2 -2
  82. package/dist/test/index.js +1 -1
  83. package/dist/test/internal/browser.d.ts +2 -2
  84. package/dist/test/internal/browser.js +1 -1
  85. package/dist/test/jsdom.d.ts +2 -2
  86. package/dist/test/locators.d.ts +294 -0
  87. package/dist/test/locators.js +1 -1
  88. package/dist/test/matchers.d.ts +29 -0
  89. package/dist/test/matchers.js +1 -1
  90. package/dist/test/node.d.ts +2 -2
  91. package/dist/test/node.js +1 -1
  92. package/dist/test/optional-runtime-types.js.d.ts +2 -2
  93. package/dist/test/optional-types.js.d.ts +2 -2
  94. package/dist/test/plugins/browser-client.js +1 -1
  95. package/dist/test/plugins/browser-context.js +1 -1
  96. package/dist/test/plugins/browser-locators.js +1 -1
  97. package/dist/test/plugins/browser-playwright.js +1 -1
  98. package/dist/test/plugins/browser-preview.js +1 -1
  99. package/dist/test/plugins/browser-webdriverio.js +1 -1
  100. package/dist/test/plugins/browser.js +1 -1
  101. package/dist/test/plugins/expect.js +1 -1
  102. package/dist/test/plugins/mocker-automock.js +1 -1
  103. package/dist/test/plugins/mocker-browser.js +1 -1
  104. package/dist/test/plugins/mocker-node.js +1 -1
  105. package/dist/test/plugins/mocker-redirect.js +1 -1
  106. package/dist/test/plugins/mocker-register.js +1 -1
  107. package/dist/test/plugins/mocker-transforms.js +1 -1
  108. package/dist/test/plugins/mocker.js +1 -1
  109. package/dist/test/plugins/pretty-format.js +1 -1
  110. package/dist/test/plugins/runner-types.js +1 -1
  111. package/dist/test/plugins/runner-utils.js +1 -1
  112. package/dist/test/plugins/runner.js +1 -1
  113. package/dist/test/plugins/snapshot-environment.js +1 -1
  114. package/dist/test/plugins/snapshot-manager.js +1 -1
  115. package/dist/test/plugins/snapshot.js +1 -1
  116. package/dist/test/plugins/spy.js +1 -1
  117. package/dist/test/plugins/utils-constants.js +1 -1
  118. package/dist/test/plugins/utils-diff.js +1 -1
  119. package/dist/test/plugins/utils-display.js +1 -1
  120. package/dist/test/plugins/utils-error.js +1 -1
  121. package/dist/test/plugins/utils-helpers.js +1 -1
  122. package/dist/test/plugins/utils-offset.js +1 -1
  123. package/dist/test/plugins/utils-resolver.js +1 -1
  124. package/dist/test/plugins/utils-serialize.js +1 -1
  125. package/dist/test/plugins/utils-source-map-node.js +1 -1
  126. package/dist/test/plugins/utils-source-map.js +1 -1
  127. package/dist/test/plugins/utils-timers.js +1 -1
  128. package/dist/test/plugins/utils.js +1 -1
  129. package/dist/test/reporters.d.ts +2 -2
  130. package/dist/test/reporters.js +1 -1
  131. package/dist/test/runners.d.ts +2 -2
  132. package/dist/test/runners.js +1 -1
  133. package/dist/test/runtime.d.ts +2 -2
  134. package/dist/test/runtime.js +1 -1
  135. package/dist/test/snapshot.d.ts +2 -2
  136. package/dist/test/snapshot.js +1 -1
  137. package/dist/test/suite.d.ts +2 -2
  138. package/dist/test/suite.js +1 -1
  139. package/dist/test/utils.js +1 -1
  140. package/dist/test/worker.d.ts +2 -2
  141. package/dist/test/worker.js +1 -1
  142. package/dist/{tsconfig-DFb5BKyT.js → tsconfig-CJ_StdFc.js} +563 -229
  143. package/dist/tsgolint-path-B-yOos8p.js +32 -0
  144. package/dist/tsgolint-path.d.ts +8 -0
  145. package/dist/tsgolint-path.js +2 -0
  146. package/dist/version.js +3 -3
  147. package/dist/versions.d.ts +1 -1
  148. package/dist/versions.js +6 -6
  149. package/dist/{workspace-NL-m9wgM.js → workspace-Cjoc1c_A.js} +11 -9
  150. package/docs/_data/team.ts +2 -1
  151. package/docs/config/create.md +36 -1
  152. package/docs/config/index.md +7 -5
  153. package/docs/guide/commit-hooks.md +9 -0
  154. package/docs/guide/create.md +106 -2
  155. package/docs/guide/env.md +33 -5
  156. package/docs/guide/index.md +5 -3
  157. package/docs/guide/install.md +31 -12
  158. package/docs/guide/migrate.md +13 -3
  159. package/docs/guide/troubleshooting.md +2 -2
  160. package/docs/guide/upgrade.md +26 -7
  161. package/docs/package.json +3 -3
  162. package/docs/pnpm-lock.yaml +298 -395
  163. package/package.json +103 -55
  164. package/templates/generator/bin/index.ts +6 -3
  165. package/templates/generator/package.json +2 -3
  166. package/templates/generator/src/template.ts +0 -2
  167. package/templates/monorepo/package.json +1 -1
  168. package/dist/constants-DCBWlNrn.js +0 -33
  169. package/dist/define-config-BR1Y88zz.cjs +0 -84
  170. package/dist/define-config-BRC7qPNE.js +0 -21
  171. package/dist/define-config-COdn-tsn.d.ts +0 -177
  172. package/dist/dist-Bapm49IR.js +0 -3
  173. package/dist/test/plugins/utils-highlight.js +0 -1
  174. /package/dist/{chunk-DnnnRqeS.js → rolldown-runtime-DnnnRqeS.js} +0 -0
@@ -1,2 +1,942 @@
1
- import '@voidzero-dev/vite-plus-test/context';
2
- export * from '@voidzero-dev/vite-plus-test/context';
1
+ import { SerializedConfig } from 'vitest'
2
+ import { StringifyOptions, CDPSession, BrowserCommands } from './internal/browser'
3
+ import { ARIARole } from './aria-role.js'
4
+ import {} from './matchers.js'
5
+
6
+ export type BufferEncoding =
7
+ | 'ascii'
8
+ | 'utf8'
9
+ | 'utf-8'
10
+ | 'utf16le'
11
+ | 'utf-16le'
12
+ | 'ucs2'
13
+ | 'ucs-2'
14
+ | 'base64'
15
+ | 'base64url'
16
+ | 'latin1'
17
+ | 'binary'
18
+ | 'hex'
19
+
20
+ export { CDPSession };
21
+
22
+ export interface ScreenshotOptions extends SelectorOptions {
23
+ /**
24
+ * The HTML element to screenshot.
25
+ */
26
+ element?: Element | Locator
27
+ /**
28
+ * Path relative to the current test file.
29
+ * @default `__screenshots__/${testFileName}/${testName}.png`
30
+ */
31
+ path?: string
32
+ /**
33
+ * Will also return the base64 encoded screenshot alongside the path.
34
+ */
35
+ base64?: boolean
36
+ /**
37
+ * Keep the screenshot on the file system. If file is not saved,
38
+ * `page.screenshot` always returns `base64` screenshot.
39
+ * @default true
40
+ */
41
+ save?: boolean
42
+ }
43
+
44
+ export interface MarkOptions {
45
+ /**
46
+ * Optional stack string used to resolve marker location.
47
+ * Useful for wrapper libraries that need to forward the end-user callsite.
48
+ */
49
+ stack?: string
50
+ }
51
+
52
+ interface StandardScreenshotComparators {
53
+ pixelmatch: {
54
+ /**
55
+ * The maximum number of pixels that are allowed to differ between the captured
56
+ * screenshot and the stored reference image.
57
+ *
58
+ * If set to `undefined`, any non-zero difference will cause the test to fail.
59
+ *
60
+ * For example, `allowedMismatchedPixels: 10` means the test will pass if 10
61
+ * or fewer pixels differ, but fail if 11 or more differ.
62
+ *
63
+ * If both this and `allowedMismatchedPixelRatio` are set, the more restrictive
64
+ * value (i.e., fewer allowed mismatches) will be used.
65
+ *
66
+ * @default undefined
67
+ */
68
+ allowedMismatchedPixels?: number | undefined
69
+ /**
70
+ * The maximum allowed ratio of differing pixels between the captured screenshot
71
+ * and the reference image.
72
+ *
73
+ * Must be a value between `0` and `1`.
74
+ *
75
+ * For example, `allowedMismatchedPixelRatio: 0.02` means the test will pass
76
+ * if up to 2% of pixels differ, but fail if more than 2% differ.
77
+ *
78
+ * If both this and `allowedMismatchedPixels` are set, the more restrictive
79
+ * value (i.e., fewer allowed mismatches) will be used.
80
+ *
81
+ * @default undefined
82
+ */
83
+ allowedMismatchedPixelRatio?: number | undefined
84
+ /**
85
+ * Acceptable perceived color difference between the same pixel in two images.
86
+ *
87
+ * Value ranges from `0` (strict) to `1` (very lenient). Lower values mean
88
+ * small differences will be detected.
89
+ *
90
+ * The comparison uses the {@link https://en.wikipedia.org/wiki/YIQ | YIQ color space}.
91
+ *
92
+ * @default 0.1
93
+ */
94
+ threshold?: number | undefined
95
+ /**
96
+ * If `true`, disables detection and ignoring of anti-aliased pixels.
97
+ *
98
+ * @default false
99
+ */
100
+ includeAA?: boolean | undefined
101
+ /**
102
+ * Blending level of unchanged pixels in the diff image.
103
+ *
104
+ * Ranges from `0` (white) to `1` (original brightness).
105
+ *
106
+ * @default 0.1
107
+ */
108
+ alpha?: number | undefined
109
+ /**
110
+ * Color used for anti-aliased pixels in the diff image.
111
+ *
112
+ * Format: `[R, G, B]`
113
+ *
114
+ * @default [255, 255, 0]
115
+ */
116
+ aaColor?: [r: number, g: number, b: number] | undefined
117
+ /**
118
+ * Color used for differing pixels in the diff image.
119
+ *
120
+ * Format: `[R, G, B]`
121
+ *
122
+ * @default [255, 0, 0]
123
+ */
124
+ diffColor?: [r: number, g: number, b: number] | undefined
125
+ /**
126
+ * Optional alternative color for dark-on-light differences, to help show
127
+ * what's added vs. removed.
128
+ *
129
+ * If not set, `diffColor` is used for all differences.
130
+ *
131
+ * Format: `[R, G, B]`
132
+ *
133
+ * @default undefined
134
+ */
135
+ diffColorAlt?: [r: number, g: number, b: number] | undefined
136
+ /**
137
+ * If `true`, shows only the diff as a mask on a transparent background,
138
+ * instead of overlaying it on the original image.
139
+ *
140
+ * Anti-aliased pixels won't be shown (if detected).
141
+ *
142
+ * @default false
143
+ */
144
+ diffMask?: boolean | undefined
145
+ }
146
+ }
147
+
148
+ export interface ScreenshotComparatorRegistry extends StandardScreenshotComparators {}
149
+
150
+ export type NonStandardScreenshotComparators = Omit<
151
+ ScreenshotComparatorRegistry,
152
+ keyof StandardScreenshotComparators
153
+ >
154
+
155
+ export interface ScreenshotMatcherOptions<
156
+ ComparatorName extends keyof ScreenshotComparatorRegistry = keyof ScreenshotComparatorRegistry
157
+ > {
158
+ /**
159
+ * The name of the comparator to use for visual diffing.
160
+ *
161
+ * Must be one of the keys from {@linkcode ScreenshotComparatorRegistry}.
162
+ *
163
+ * @defaultValue `'pixelmatch'`
164
+ */
165
+ comparatorName?: ComparatorName
166
+ comparatorOptions?: ScreenshotComparatorRegistry[ComparatorName]
167
+ screenshotOptions?: Omit<
168
+ ScreenshotOptions,
169
+ 'element' | 'base64' | 'path' | 'save' | 'type' | 'strict' | 'timeout'
170
+ >
171
+ /**
172
+ * Time to wait until a stable screenshot is found.
173
+ *
174
+ * Setting this value to `0` disables the timeout, but if a stable screenshot
175
+ * can't be determined the process will not end.
176
+ *
177
+ * @default 5000
178
+ */
179
+ timeout?: number
180
+ /**
181
+ * Allow only a single element with the same locator.
182
+ *
183
+ * If Vitest finds multiple elements, it will throw an error immediately without retrying.
184
+ * @default true
185
+ */
186
+ strict?: boolean
187
+ }
188
+
189
+ export interface UserEvent {
190
+ /**
191
+ * Creates a new user event instance. This is useful if you need to keep the
192
+ * state of keyboard to press and release buttons correctly.
193
+ *
194
+ * **Note:** Unlike `@testing-library/user-event`, the default `userEvent` instance
195
+ * from `vitest/browser` is created once, not every time its methods are called!
196
+ * @see {@link https://vitest.dev/api/browser/interactivity.html#userevent-setup}
197
+ */
198
+ setup: () => UserEvent
199
+ /**
200
+ * Cleans up the user event instance, releasing any resources or state it holds,
201
+ * such as keyboard press state. For the default `userEvent` instance, this method
202
+ * is automatically called after each test case.
203
+ */
204
+ cleanup: () => Promise<void>
205
+ /**
206
+ * Click on an element. Uses provider's API under the hood and supports all its options.
207
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-click} Playwright API
208
+ * @see {@link https://webdriver.io/docs/api/element/click/} WebdriverIO API
209
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#click} testing-library API
210
+ */
211
+ click: (element: Element | Locator, options?: UserEventClickOptions) => Promise<void>
212
+ /**
213
+ * Triggers a double click event on an element. Uses provider's API under the hood.
214
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-dblclick} Playwright API
215
+ * @see {@link https://webdriver.io/docs/api/element/doubleClick/} WebdriverIO API
216
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#dblClick} testing-library API
217
+ */
218
+ dblClick: (element: Element | Locator, options?: UserEventDoubleClickOptions) => Promise<void>
219
+ /**
220
+ * Triggers a triple click event on an element. Uses provider's API under the hood.
221
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-click} Playwright API: using `click` with `clickCount: 3`
222
+ * @see {@link https://webdriver.io/docs/api/browser/actions/} WebdriverIO API: using actions api with `move` plus three `down + up + pause` events in a row
223
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#tripleclick} testing-library API
224
+ */
225
+ tripleClick: (element: Element | Locator, options?: UserEventTripleClickOptions) => Promise<void>
226
+ /**
227
+ * Triggers a {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event|`wheel` event} on an element.
228
+ *
229
+ * @param element - The target element to receive wheel events.
230
+ * @param options - Scroll configuration using `delta` or `direction`.
231
+ * @returns A promise that resolves when all wheel events have been dispatched.
232
+ *
233
+ * @since 4.1.0
234
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-wheel}
235
+ *
236
+ * @example
237
+ * // Scroll down by 100 pixels
238
+ * await userEvent.wheel(container, { delta: { y: 100 } })
239
+ *
240
+ * @example
241
+ * // Scroll up 5 times
242
+ * await userEvent.wheel(container, { direction: 'up', times: 5 })
243
+ */
244
+ wheel(element: Element | Locator, options: UserEventWheelOptions): Promise<void>
245
+ /**
246
+ * Choose one or more values from a select element. Uses provider's API under the hood.
247
+ * If select doesn't have `multiple` attribute, only the first value will be selected.
248
+ * @example
249
+ * await userEvent.selectOptions(select, 'Option 1')
250
+ * expect(select).toHaveValue('option-1')
251
+ *
252
+ * await userEvent.selectOptions(select, 'option-1')
253
+ * expect(select).toHaveValue('option-1')
254
+ *
255
+ * await userEvent.selectOptions(select, [
256
+ * screen.getByRole('option', { name: 'Option 1' }),
257
+ * screen.getByRole('option', { name: 'Option 2' }),
258
+ * ])
259
+ * expect(select).toHaveValue(['option-1', 'option-2'])
260
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-select-option} Playwright API
261
+ * @see {@link https://webdriver.io/docs/api/element/doubleClick/} WebdriverIO API
262
+ * @see {@link https://testing-library.com/docs/user-event/utility/#-selectoptions-deselectoptions} testing-library API
263
+ */
264
+ selectOptions: (
265
+ element: HTMLElement | SVGElement | Locator,
266
+ values: HTMLElement | HTMLElement[] | Locator | Locator[] | string | string[],
267
+ options?: UserEventSelectOptions,
268
+ ) => Promise<void>
269
+ /**
270
+ * Type text on the keyboard. If any input is focused, it will receive the text,
271
+ * otherwise it will be typed on the document. Uses provider's API under the hood.
272
+ * **Supports** [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard) (e.g., `{Shift}`) even with `playwright` and `webdriverio` providers.
273
+ * @example
274
+ * await userEvent.keyboard('foo') // translates to: f, o, o
275
+ * await userEvent.keyboard('{{a[[') // translates to: {, a, [
276
+ * await userEvent.keyboard('{Shift}{f}{o}{o}') // translates to: Shift, f, o, o
277
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
278
+ * @see {@link https://webdriver.io/docs/api/browser/keys} WebdriverIO API
279
+ * @see {@link https://testing-library.com/docs/user-event/keyboard} testing-library API
280
+ */
281
+ keyboard: (text: string) => Promise<void>
282
+ /**
283
+ * Types text into an element. Uses provider's API under the hood.
284
+ * **Supports** [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard) (e.g., `{Shift}`) even with `playwright` and `webdriverio` providers.
285
+ * This method can be significantly slower than `userEvent.fill`, so it should be used only when necessary.
286
+ * @example
287
+ * await userEvent.type(input, 'foo') // translates to: f, o, o
288
+ * await userEvent.type(input, '{{a[[') // translates to: {, a, [
289
+ * await userEvent.type(input, '{Shift}{f}{o}{o}') // translates to: Shift, f, o, o
290
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-press} Playwright API
291
+ * @see {@link https://webdriver.io/docs/api/browser/action#key-input-source} WebdriverIO API
292
+ * @see {@link https://testing-library.com/docs/user-event/utility/#type} testing-library API
293
+ */
294
+ type: (element: Element | Locator, text: string, options?: UserEventTypeOptions) => Promise<void>
295
+ /**
296
+ * Removes all text from an element. Uses provider's API under the hood.
297
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-clear} Playwright API
298
+ * @see {@link https://webdriver.io/docs/api/element/clearValue} WebdriverIO API
299
+ * @see {@link https://testing-library.com/docs/user-event/utility/#clear} testing-library API
300
+ */
301
+ clear: (element: Element | Locator, options?: UserEventClearOptions) => Promise<void>
302
+ /**
303
+ * Sends a `Tab` key event. Uses provider's API under the hood.
304
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
305
+ * @see {@link https://webdriver.io/docs/api/element/keys} WebdriverIO API
306
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#tab} testing-library API
307
+ */
308
+ tab: (options?: UserEventTabOptions) => Promise<void>
309
+ /**
310
+ * Hovers over an element. Uses provider's API under the hood.
311
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-hover} Playwright API
312
+ * @see {@link https://webdriver.io/docs/api/element/moveTo/} WebdriverIO API
313
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#hover} testing-library API
314
+ */
315
+ hover: (element: Element | Locator, options?: UserEventHoverOptions) => Promise<void>
316
+ /**
317
+ * Moves cursor position to the body element. Uses provider's API under the hood.
318
+ * By default, the cursor position is in the center (in webdriverio) or in some visible place (in playwright)
319
+ * of the body element, so if the current element is already there, this will have no effect.
320
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-hover} Playwright API
321
+ * @see {@link https://webdriver.io/docs/api/element/moveTo/} WebdriverIO API
322
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#hover} testing-library API
323
+ */
324
+ unhover: (element: Element | Locator, options?: UserEventHoverOptions) => Promise<void>
325
+ /**
326
+ * Change a file input element to have the specified files. Uses provider's API under the hood.
327
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-set-input-files} Playwright API
328
+ * @see {@link https://testing-library.com/docs/user-event/utility#upload} testing-library API
329
+ */
330
+ upload: (element: Element | Locator, files: File | File[] | string | string[], options?: UserEventUploadOptions) => Promise<void>
331
+ /**
332
+ * Copies the selected content.
333
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
334
+ * @see {@link https://webdriver.io/docs/api/browser/keys//} WebdriverIO API
335
+ * @see {@link https://testing-library.com/docs/user-event/clipboard#copy} testing-library API
336
+ */
337
+ copy: () => Promise<void>
338
+ /**
339
+ * Cuts the selected content.
340
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
341
+ * @see {@link https://webdriver.io/docs/api/browser/keys//} WebdriverIO API
342
+ * @see {@link https://testing-library.com/docs/user-event/clipboard#cut} testing-library API
343
+ */
344
+ cut: () => Promise<void>
345
+ /**
346
+ * Pastes the copied or cut content.
347
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
348
+ * @see {@link https://webdriver.io/docs/api/browser/keys//} WebdriverIO API
349
+ * @see {@link https://testing-library.com/docs/user-event/clipboard#paste} testing-library API
350
+ */
351
+ paste: () => Promise<void>
352
+ /**
353
+ * Fills an input element with text. This will remove any existing text in the input before typing the new text.
354
+ * Uses provider's API under the hood.
355
+ * This API is faster than using `userEvent.type` or `userEvent.keyboard`, but it **doesn't support** [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard) (e.g., `{Shift}`).
356
+ * @example
357
+ * await userEvent.fill(input, 'foo') // translates to: f, o, o
358
+ * await userEvent.fill(input, '{{a[[') // translates to: {, {, a, [, [
359
+ * await userEvent.fill(input, '{Shift}') // translates to: {, S, h, i, f, t, }
360
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-fill} Playwright API
361
+ * @see {@link https://webdriver.io/docs/api/element/setValue} WebdriverIO API
362
+ * @see {@link https://testing-library.com/docs/user-event/utility/#type} testing-library API
363
+ */
364
+ fill: (element: Element | Locator, text: string, options?: UserEventFillOptions) => Promise<void>
365
+ /**
366
+ * Drags a source element on top of the target element. This API is not supported by "preview" provider.
367
+ * @see {@link https://playwright.dev/docs/api/class-frame#frame-drag-and-drop} Playwright API
368
+ * @see {@link https://webdriver.io/docs/api/element/dragAndDrop/} WebdriverIO API
369
+ */
370
+ dragAndDrop: (source: Element | Locator, target: Element | Locator, options?: UserEventDragAndDropOptions) => Promise<void>
371
+ }
372
+
373
+ export interface UserEventFillOptions {}
374
+ export interface UserEventHoverOptions {}
375
+ export interface UserEventSelectOptions {}
376
+ export interface UserEventClickOptions {}
377
+ export interface UserEventClearOptions {}
378
+ export interface UserEventDoubleClickOptions {}
379
+ export interface UserEventTripleClickOptions {}
380
+ export interface UserEventDragAndDropOptions {}
381
+ export interface UserEventUploadOptions {}
382
+
383
+ /**
384
+ * Base options shared by all wheel event configurations.
385
+ *
386
+ * @since 4.1.0
387
+ */
388
+ export interface UserEventWheelBaseOptions {
389
+ /**
390
+ * Number of wheel events to fire. Defaults to `1`.
391
+ *
392
+ * Useful for triggering multiple scroll steps in a single call.
393
+ */
394
+ times?: number
395
+ }
396
+
397
+ /**
398
+ * Wheel options using pixel-based `delta` values for precise scroll control.
399
+ *
400
+ * @since 4.1.0
401
+ */
402
+ export interface UserEventWheelDeltaOptions extends UserEventWheelBaseOptions {
403
+ /**
404
+ * Precise scroll delta values in pixels. At least one axis must be specified.
405
+ *
406
+ * - Positive `y` scrolls down, negative `y` scrolls up.
407
+ * - Positive `x` scrolls right, negative `x` scrolls left.
408
+ */
409
+ delta: { x: number; y?: number } | { x?: number; y: number }
410
+ direction?: undefined
411
+ }
412
+
413
+ /**
414
+ * Wheel options using semantic `direction` values for simpler scroll control.
415
+ *
416
+ * @since 4.1.0
417
+ */
418
+ export interface UserEventWheelDirectionOptions extends UserEventWheelBaseOptions {
419
+ /**
420
+ * Semantic scroll direction. Use this for readable tests when exact pixel values don't matter.
421
+ */
422
+ direction: 'up' | 'down' | 'left' | 'right'
423
+ delta?: undefined
424
+ }
425
+
426
+ /**
427
+ * Options for triggering wheel events.
428
+ *
429
+ * Specify scrolling using either `delta` for precise pixel values, or `direction` for semantic scrolling. These are mutually exclusive.
430
+ *
431
+ * @since 4.1.0
432
+ */
433
+ export type UserEventWheelOptions = UserEventWheelDeltaOptions | UserEventWheelDirectionOptions
434
+
435
+ export interface LocatorOptions {
436
+ /**
437
+ * Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a
438
+ * regular expression. Note that exact match still trims whitespace.
439
+ */
440
+ exact?: boolean
441
+ hasText?: string | RegExp
442
+ hasNotText?: string | RegExp
443
+ has?: Locator
444
+ hasNot?: Locator
445
+ }
446
+
447
+ export interface LocatorByRoleOptions extends LocatorOptions {
448
+ /**
449
+ * Should checked elements (set by `aria-checked` or `<input type="checkbox"/>`) be included or not. By default, the filter is not applied.
450
+ *
451
+ * See [`aria-checked`](https://www.w3.org/TR/wai-aria-1.2/#aria-checked) for more information
452
+ */
453
+ checked?: boolean
454
+ /**
455
+ * Should disabled elements be included or not. By default, the filter is not applied. Note that unlike other attributes, `disable` state is inherited.
456
+ *
457
+ * See [`aria-disabled`](https://www.w3.org/TR/wai-aria-1.2/#aria-disabled) for more information
458
+ */
459
+ disabled?: boolean
460
+ /**
461
+ * Should expanded elements be included or not. By default, the filter is not applied.
462
+ *
463
+ * See [`aria-expanded`](https://www.w3.org/TR/wai-aria-1.2/#aria-expanded) for more information
464
+ */
465
+ expanded?: boolean
466
+ /**
467
+ * Should elements that are [normally excluded](https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion) from the accessibility tree be queried. By default, only non-hidden elements are matched by role selector.
468
+ *
469
+ * Note that roles `none` and `presentation` are always included.
470
+ * @default false
471
+ */
472
+ includeHidden?: boolean
473
+ /**
474
+ * A number attribute that is usually present for `heading`, `listitem`, `row`, `treeitem` roles with default values for `<h1>-<h6>` elements. By default, the filter is not applied.
475
+ *
476
+ * See [`aria-level`](https://www.w3.org/TR/wai-aria-1.2/#aria-level) for more information
477
+ */
478
+ level?: number
479
+ /**
480
+ * Option to match the [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). By default, matching is
481
+ * case-insensitive and searches for a substring, use `exact` to control this behavior.
482
+ */
483
+ name?: string | RegExp
484
+ /**
485
+ * Should pressed elements be included or not. By default, the filter is not applied.
486
+ *
487
+ * See [`aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed) for more information
488
+ */
489
+ pressed?: boolean
490
+ /**
491
+ * Should selected elements be included or not. By default, the filter is not applied.
492
+ *
493
+ * See [`aria-selected`](https://www.w3.org/TR/wai-aria-1.2/#aria-selected) for more information
494
+ */
495
+ selected?: boolean
496
+ }
497
+
498
+ export interface LocatorScreenshotOptions extends Omit<ScreenshotOptions, 'element'> {}
499
+
500
+ export interface LocatorSelectors {
501
+ /**
502
+ * Creates a way to locate an element by its [ARIA role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles), [ARIA attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes) and [accessible name](https://developer.mozilla.org/en-US/docs/Glossary/Accessible_name).
503
+ * @see {@link https://vitest.dev/api/browser/locators#getbyrole}
504
+ */
505
+ getByRole: (role: ARIARole | ({} & string), options?: LocatorByRoleOptions) => Locator
506
+ /**
507
+ * @see {@link https://vitest.dev/api/browser/locators#getbylabeltext}
508
+ */
509
+ getByLabelText: (text: string | RegExp, options?: LocatorOptions) => Locator
510
+ /**
511
+ * Creates a locator capable of finding an element with an `alt` attribute that matches the text. Unlike testing-library's implementation, Vitest will match any element that has an `alt` attribute.
512
+ * @see {@link https://vitest.dev/api/browser/locators#getbyalttext}
513
+ */
514
+ getByAltText: (text: string | RegExp, options?: LocatorOptions) => Locator
515
+ /**
516
+ * Creates a locator capable of finding an element that has the specified placeholder text. Vitest will match any element that has a matching `placeholder` attribute, not just `input`.
517
+ * @see {@link https://vitest.dev/api/browser/locators#getbyplaceholder}
518
+ */
519
+ getByPlaceholder: (text: string | RegExp, options?: LocatorOptions) => Locator
520
+ /**
521
+ * Creates a locator capable of finding an element that contains the specified text. The text will be matched against TextNode's [`nodeValue`](https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeValue) or input's value if the type is `button` or `reset`.
522
+ * Matching by text always normalizes whitespace, even with exact match.
523
+ * For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
524
+ * @see {@link https://vitest.dev/api/browser/locators#getbytext}
525
+ */
526
+ getByText: (text: string | RegExp, options?: LocatorOptions) => Locator
527
+ /**
528
+ * Creates a locator capable of finding an element that has the specified `title` attribute. Unlike testing-library's `getByTitle`, Vitest cannot find `title` elements within an SVG.
529
+ * @see {@link https://vitest.dev/api/browser/locators#getbytitle}
530
+ */
531
+ getByTitle: (text: string | RegExp, options?: LocatorOptions) => Locator
532
+ /**
533
+ * Creates a locator capable of finding an element that matches the specified test id attribute. You can configure the attribute name with [`browser.locators.testIdAttribute`](https://vitest.dev/config/browser/locators#browser-locators-testidattribute).
534
+ * @see {@link https://vitest.dev/api/browser/locators#getbytestid}
535
+ */
536
+ getByTestId: (text: string | RegExp) => Locator
537
+ }
538
+
539
+ export interface FrameLocator extends LocatorSelectors {}
540
+
541
+ export interface SelectorOptions {
542
+ /**
543
+ * How long to wait until a single element is found. By default, this has the same timeout as the test.
544
+ *
545
+ * Vitest will try to find the element in ever increasing intervals: 0, 20, 50, 100, 100, 500.
546
+ */
547
+ timeout?: number
548
+ /**
549
+ * Allow only a single element with the same locator.
550
+ *
551
+ * If Vitest finds multiple elements, it will throw an error immediately without retrying.
552
+ * @default true
553
+ */
554
+ strict?: boolean
555
+ }
556
+
557
+ export interface Locator extends LocatorSelectors {
558
+ /**
559
+ * Selector string that will be used to locate the element by the browser provider.
560
+ * You can use this string in the commands API:
561
+ * ```ts
562
+ * // playwright
563
+ * function test({ selector, iframe }) {
564
+ * await iframe.locator(selector).click()
565
+ * }
566
+ * // webdriverio
567
+ * function test({ selector, browser }) {
568
+ * await browser.$(selector).click()
569
+ * }
570
+ * ```
571
+ * @see {@link https://vitest.dev/api/browser/locators#selector}
572
+ */
573
+ readonly selector: string
574
+
575
+ /**
576
+ * The number of elements that this locator is matching.
577
+ * @see {@link https://vitest.dev/api/browser/locators#length}
578
+ */
579
+ readonly length: number
580
+
581
+ /**
582
+ * Click on an element. You can use the options to set the cursor position.
583
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-click}
584
+ */
585
+ click(options?: UserEventClickOptions): Promise<void>
586
+ /**
587
+ * Triggers a double click event on an element. You can use the options to set the cursor position.
588
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-dblclick}
589
+ */
590
+ dblClick(options?: UserEventDoubleClickOptions): Promise<void>
591
+ /**
592
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-tripleclick}
593
+ */
594
+ tripleClick(options?: UserEventTripleClickOptions): Promise<void>
595
+ /**
596
+ * Triggers a {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event|`wheel` event} on an element.
597
+ *
598
+ * @param options - Scroll configuration using `delta` or `direction`.
599
+ * @returns A promise that resolves when all wheel events have been dispatched.
600
+ *
601
+ * @since 4.1.0
602
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-wheel}
603
+ *
604
+ * @example
605
+ * // Scroll down by 100 pixels
606
+ * await container.wheel({ delta: { y: 100 } })
607
+ *
608
+ * @example
609
+ * // Scroll up 5 times
610
+ * await container.wheel({ direction: 'up', times: 5 })
611
+ */
612
+ wheel(options: UserEventWheelOptions): Promise<void>
613
+ /**
614
+ * Clears the input element content
615
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-clear}
616
+ */
617
+ clear(options?: UserEventClearOptions): Promise<void>
618
+ /**
619
+ * Moves the cursor position to the selected element
620
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-hover}
621
+ */
622
+ hover(options?: UserEventHoverOptions): Promise<void>
623
+ /**
624
+ * This works the same as `locator.hover`, but moves the cursor to the `document.body` element instead.
625
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-unhover}
626
+ */
627
+ unhover(options?: UserEventHoverOptions): Promise<void>
628
+ /**
629
+ * Sets the value of the current `input`, `textarea` or `contenteditable` element.
630
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-fill}
631
+ */
632
+ fill(text: string, options?: UserEventFillOptions): Promise<void>
633
+ /**
634
+ * Drags the current element to the target location.
635
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-dropto}
636
+ */
637
+ dropTo(target: Locator, options?: UserEventDragAndDropOptions): Promise<void>
638
+ /**
639
+ * Choose one or more values from a `<select>` element.
640
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-selectoptions}
641
+ */
642
+ selectOptions(
643
+ values: HTMLElement | HTMLElement[] | Locator | Locator[] | string | string[],
644
+ options?: UserEventSelectOptions,
645
+ ): Promise<void>
646
+ /**
647
+ * Change a file input element to have the specified files. Uses provider's API under the hood.
648
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-upload}
649
+ */
650
+ upload(files: File | File[] | string | string[], options?: UserEventUploadOptions): Promise<void>
651
+
652
+ /**
653
+ * Make a screenshot of an element matching the locator.
654
+ * @see {@link https://vitest.dev/api/browser/locators#screenshot}
655
+ */
656
+ screenshot(options: Omit<LocatorScreenshotOptions, 'base64'> & { base64: true }): Promise<{
657
+ path: string
658
+ base64: string
659
+ }>
660
+ screenshot(options?: LocatorScreenshotOptions): Promise<string>
661
+
662
+ /**
663
+ * Add a trace marker for this locator when browser tracing is enabled.
664
+ * @see {@link https://vitest.dev/api/browser/locators#mark}
665
+ */
666
+ mark(name: string, options?: MarkOptions): Promise<void>
667
+
668
+ /**
669
+ * Returns an element matching the selector.
670
+ *
671
+ * - If multiple elements match the selector, an error is thrown.
672
+ * - If no elements match the selector, an error is thrown.
673
+ *
674
+ * @see {@link https://vitest.dev/api/browser/locators#element}
675
+ */
676
+ element(): HTMLElement | SVGElement
677
+ /**
678
+ * Returns an array of elements matching the selector.
679
+ *
680
+ * If no elements match the selector, an empty array is returned.
681
+ *
682
+ * @see {@link https://vitest.dev/api/browser/locators#elements}
683
+ */
684
+ elements(): (HTMLElement | SVGElement)[]
685
+ /**
686
+ * Returns an element matching the selector.
687
+ *
688
+ * - If multiple elements match the selector, an error is thrown.
689
+ * - If no elements match the selector, returns `null`.
690
+ *
691
+ * @see {@link https://vitest.dev/api/browser/locators#query}
692
+ */
693
+ query(): HTMLElement | SVGElement | null
694
+ /**
695
+ * Wraps an array of `.elements()` matching the selector in a new `Locator`.
696
+ *
697
+ * @see {@link https://vitest.dev/api/browser/locators#all}
698
+ */
699
+ all(): Locator[]
700
+ /**
701
+ * Returns a locator for the nth element matching the selector.
702
+ * @see {@link https://vitest.dev/api/browser/locators#nth}
703
+ */
704
+ nth(index: number): Locator
705
+ /**
706
+ * Returns a locator for the first element matching the selector.
707
+ * @see {@link https://vitest.dev/api/browser/locators#first}
708
+ */
709
+ first(): Locator
710
+ /**
711
+ * Returns a locator for the last element matching the selector.
712
+ * @see {@link https://vitest.dev/api/browser/locators#last}
713
+ */
714
+ last(): Locator
715
+ /**
716
+ * Returns a locator that matches both the current locator and the provided locator.
717
+ * @see {@link https://vitest.dev/api/browser/locators#and}
718
+ */
719
+ and(locator: Locator): Locator
720
+ /**
721
+ * Returns a locator that matches either the current locator or the provided locator.
722
+ * @see {@link https://vitest.dev/api/browser/locators#or}
723
+ */
724
+ or(locator: Locator): Locator
725
+ /**
726
+ * Narrows existing locator according to the options.
727
+ * @see {@link https://vitest.dev/api/browser/locators#filter}
728
+ */
729
+ filter(options: LocatorOptions): Locator
730
+ /**
731
+ * This method returns an element matching the locator.
732
+ * Unlike [`.element()`](https://vitest.dev/api/browser/locators#element),
733
+ * this method will wait and retry until a matching element appears in the DOM,
734
+ * using increasing intervals (0, 20, 50, 100, 100, 500ms).
735
+ *
736
+ * **WARNING:**
737
+ *
738
+ * This is an escape hatch for library authors and 3d-party APIs that do not support locators directly.
739
+ * If you are interacting with the element, use builtin methods instead.
740
+ * @since 4.1.0
741
+ * @see {@link https://vitest.dev/api/browser/locators#findelement}
742
+ */
743
+ findElement(options?: SelectorOptions): Promise<HTMLElement | SVGElement>
744
+ }
745
+
746
+ export interface UserEventTabOptions {
747
+ shift?: boolean
748
+ }
749
+
750
+ export interface UserEventTypeOptions extends SelectorOptions {
751
+ skipClick?: boolean
752
+ skipAutoClose?: boolean
753
+ }
754
+
755
+ type Platform =
756
+ | 'aix'
757
+ | 'android'
758
+ | 'darwin'
759
+ | 'freebsd'
760
+ | 'haiku'
761
+ | 'linux'
762
+ | 'openbsd'
763
+ | 'sunos'
764
+ | 'win32'
765
+ | 'cygwin'
766
+ | 'netbsd'
767
+
768
+ export const server: {
769
+ /**
770
+ * Platform the Vitest server is running on.
771
+ * The same as calling `process.platform` on the server.
772
+ */
773
+ platform: Platform
774
+ /**
775
+ * Runtime version of the Vitest server.
776
+ * The same as calling `process.version` on the server.
777
+ */
778
+ version: string
779
+ /**
780
+ * Name of the browser provider.
781
+ */
782
+ provider: string
783
+ /**
784
+ * Name of the current browser.
785
+ */
786
+ browser: string
787
+ /**
788
+ * Available commands for the browser.
789
+ * @see {@link https://vitest.dev/api/browser/commands}
790
+ */
791
+ commands: BrowserCommands
792
+ /**
793
+ * Serialized test config.
794
+ */
795
+ config: SerializedConfig
796
+ }
797
+
798
+ /**
799
+ * Handler for user interactions. The support is provided by the browser provider (`playwright` or `webdriverio`).
800
+ * If used with `preview` provider, fallbacks to simulated events via `@testing-library/user-event`.
801
+ * @experimental
802
+ */
803
+ export const userEvent: UserEvent
804
+
805
+ /**
806
+ * Available commands for the browser.
807
+ * A shortcut to `server.commands`.
808
+ * @see {@link https://vitest.dev/api/browser/commands}
809
+ */
810
+ export const commands: BrowserCommands
811
+
812
+ export interface BrowserPage extends LocatorSelectors {
813
+ /**
814
+ * Change the size of iframe's viewport.
815
+ */
816
+ viewport(width: number, height: number): Promise<void>
817
+ /**
818
+ * Make a screenshot of the test iframe or a specific element.
819
+ * @returns Path to the screenshot file or path and base64.
820
+ */
821
+ screenshot(options: Omit<ScreenshotOptions, 'save'> & { save: false }): Promise<string>
822
+ screenshot(options: Omit<ScreenshotOptions, 'base64'> & { base64: true }): Promise<{
823
+ path: string
824
+ base64: string
825
+ }>
826
+ screenshot(options?: Omit<ScreenshotOptions, 'base64'>): Promise<string>
827
+ screenshot(options?: ScreenshotOptions): Promise<string | {
828
+ path: string
829
+ base64: string
830
+ }>
831
+ /**
832
+ * Add a trace marker when browser tracing is enabled.
833
+ * @see {@link https://vitest.dev/api/browser/context#mark}
834
+ */
835
+ mark(name: string, options?: MarkOptions): Promise<void>
836
+ /**
837
+ * Group multiple operations under a trace marker when browser tracing is enabled.
838
+ * @see {@link https://vitest.dev/api/browser/context#mark}
839
+ */
840
+ mark<T>(name: string, body: () => T | Promise<T>, options?: MarkOptions): Promise<T>
841
+ /**
842
+ * Extend default `page` object with custom methods.
843
+ */
844
+ extend(methods: Partial<BrowserPage>): BrowserPage
845
+ /**
846
+ * Wrap an HTML element in a `Locator`. When querying for elements, the search will always return this element.
847
+ * @see {@link https://vitest.dev/api/browser/locators}
848
+ */
849
+ elementLocator(element: Element): Locator
850
+ /**
851
+ * The iframe locator. This is a document locator that enters the iframe body
852
+ * and works similarly to the `page` object.
853
+ *
854
+ * As the first argument, pass down the locator to the `<iframe>` element itself.
855
+ *
856
+ * **Warning:** At the moment, this is supported only by the `playwright` provider.
857
+ * @example
858
+ * ```ts
859
+ * const frame = page.frameLocator(
860
+ * page.getByTestId('iframe')
861
+ * )
862
+ *
863
+ * await frame.getByText('Hello World').click()
864
+ * ```
865
+ * @param locator The locator object.
866
+ * @see {@link https://vitest.dev/api/browser/locators}
867
+ */
868
+ frameLocator(locator: Locator): FrameLocator
869
+ }
870
+
871
+ export interface BrowserLocators {
872
+ createElementLocators(element: Element): LocatorSelectors
873
+ // TODO: enhance docs
874
+ /**
875
+ * Extends `page.*` and `locator.*` interfaces.
876
+ * @see {@link}
877
+ *
878
+ * @example
879
+ * ```ts
880
+ * import { locators } from './browser'
881
+ *
882
+ * declare module './browser' {
883
+ * interface LocatorSelectors {
884
+ * getByCSS(css: string): Locator
885
+ * }
886
+ * }
887
+ *
888
+ * locators.extend({
889
+ * getByCSS(css: string) {
890
+ * return `css=${css}`
891
+ * }
892
+ * })
893
+ * ```
894
+ */
895
+ extend(methods: {
896
+ [K in keyof LocatorSelectors]?: (
897
+ this: BrowserPage | Locator,
898
+ ...args: Parameters<LocatorSelectors[K]>
899
+ ) => ReturnType<LocatorSelectors[K]> | string
900
+ }): void
901
+ }
902
+
903
+
904
+ export type PrettyDOMOptions = Omit<StringifyOptions, 'maxLength'>
905
+
906
+ export const utils: {
907
+ /**
908
+ * This is similar to calling `page.elementLocator`, but it returns only
909
+ * locator selectors.
910
+ */
911
+ getElementLocatorSelectors(element: Element): LocatorSelectors
912
+ /**
913
+ * Prints prettified HTML of an element.
914
+ */
915
+ debug(
916
+ el?: Element | Locator | null | (Element | Locator)[],
917
+ maxLength?: number,
918
+ options?: PrettyDOMOptions,
919
+ ): void
920
+ /**
921
+ * Returns prettified HTML of an element.
922
+ */
923
+ prettyDOM(
924
+ dom?: Element | Locator | undefined | null,
925
+ maxLength?: number,
926
+ prettyFormatOptions?: PrettyDOMOptions,
927
+ ): string
928
+ /**
929
+ * Configures default options of `prettyDOM` and `debug` functions.
930
+ * This will also affect `vitest-browser-{framework}` package.
931
+ */
932
+ configurePrettyDOM(options: StringifyOptions): void
933
+ /**
934
+ * Creates "Cannot find element" error. Useful for custom locators.
935
+ */
936
+ getElementError(selector: string, container?: Element): Error
937
+ }
938
+
939
+ export const locators: BrowserLocators
940
+
941
+ export const page: BrowserPage
942
+ export const cdp: () => CDPSession