@voidzero-dev/vite-plus-test 0.1.9 → 0.1.11

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 (206) hide show
  1. package/LICENSE.md +181 -1
  2. package/dist/@vitest/browser/client/.vite/manifest.json +6 -6
  3. package/dist/@vitest/browser/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
  4. package/dist/@vitest/browser/client/__vitest__/assets/index-Di71CKDo.js +63 -0
  5. package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
  6. package/dist/@vitest/browser/client/__vitest__/favicon.svg +49 -4
  7. package/dist/@vitest/browser/client/__vitest__/index.html +2 -2
  8. package/dist/@vitest/browser/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
  9. package/dist/@vitest/browser/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +168 -59
  10. package/dist/@vitest/browser/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
  11. package/dist/@vitest/browser/client/favicon.svg +49 -4
  12. package/dist/@vitest/browser/client/orchestrator.html +2 -2
  13. package/dist/@vitest/browser/client/tester/tester.html +2 -2
  14. package/dist/@vitest/browser/client.js +20 -13
  15. package/dist/@vitest/browser/context.d.ts +160 -10
  16. package/dist/@vitest/browser/context.js +108 -22
  17. package/dist/@vitest/browser/expect-element.js +23 -28
  18. package/dist/@vitest/browser/index-5Pe7X7sp.js +7 -0
  19. package/dist/@vitest/browser/index.d.ts +20 -2
  20. package/dist/@vitest/browser/index.js +5706 -159
  21. package/dist/@vitest/browser/locators.d.ts +14 -3
  22. package/dist/@vitest/browser/locators.js +1 -1
  23. package/dist/@vitest/browser-playwright/index.d.ts +23 -6
  24. package/dist/@vitest/browser-playwright/index.js +169 -61
  25. package/dist/@vitest/browser-playwright/locators.js +1 -1
  26. package/dist/@vitest/browser-preview/index.d.ts +14 -1
  27. package/dist/@vitest/browser-preview/locators.js +32 -20
  28. package/dist/@vitest/browser-webdriverio/index.d.ts +17 -3
  29. package/dist/@vitest/browser-webdriverio/index.js +22 -2
  30. package/dist/@vitest/browser-webdriverio/locators.js +85 -9
  31. package/dist/@vitest/expect/index.d.ts +172 -54
  32. package/dist/@vitest/expect/index.js +124 -67
  33. package/dist/@vitest/mocker/auto-register.js +1 -0
  34. package/dist/@vitest/mocker/automock.d.ts +1 -0
  35. package/dist/@vitest/mocker/automock.js +5 -0
  36. package/dist/@vitest/mocker/browser.d.ts +4 -4
  37. package/dist/@vitest/mocker/browser.js +1 -0
  38. package/dist/@vitest/mocker/chunk-automock.js +182 -14
  39. package/dist/@vitest/mocker/chunk-helpers.js +44 -0
  40. package/dist/@vitest/mocker/chunk-hoistMocks.js +659 -0
  41. package/dist/@vitest/mocker/chunk-mocker.js +41 -30
  42. package/dist/@vitest/mocker/chunk-registry.js +21 -7
  43. package/dist/@vitest/mocker/chunk-utils.js +18 -7
  44. package/dist/@vitest/mocker/hoistMocks.d-w2ILr1dG.d.ts +739 -0
  45. package/dist/@vitest/mocker/{index.d-C-sLYZi-.d.ts → index.d-B41z0AuW.d.ts} +1 -1
  46. package/dist/@vitest/mocker/index.d.ts +2 -2
  47. package/dist/@vitest/mocker/index.js +18 -3
  48. package/dist/@vitest/mocker/{mocker.d-TnKRhz7N.d.ts → mocker.d-QEntlm6J.d.ts} +10 -5
  49. package/dist/@vitest/mocker/node.d.ts +5 -734
  50. package/dist/@vitest/mocker/node.js +29 -587
  51. package/dist/@vitest/mocker/redirect.js +4 -4
  52. package/dist/@vitest/mocker/register.d.ts +3 -3
  53. package/dist/@vitest/mocker/register.js +1 -0
  54. package/dist/@vitest/mocker/transforms.d.ts +6 -0
  55. package/dist/@vitest/mocker/transforms.js +8 -0
  56. package/dist/@vitest/mocker/{types.d-B8CCKmHt.d.ts → types.d-BjI5eAwu.d.ts} +23 -7
  57. package/dist/@vitest/pretty-format/index.d.ts +11 -1
  58. package/dist/@vitest/pretty-format/index.js +33 -4
  59. package/dist/@vitest/runner/chunk-tasks.js +305 -37
  60. package/dist/@vitest/runner/index.d.ts +5 -6
  61. package/dist/@vitest/runner/index.js +1146 -455
  62. package/dist/@vitest/runner/{tasks.d-C7UxawJ9.d.ts → tasks.d-D2GKpdwQ.d.ts} +726 -55
  63. package/dist/@vitest/runner/types.d.ts +2 -182
  64. package/dist/@vitest/runner/utils.d.ts +16 -8
  65. package/dist/@vitest/runner/utils.js +1 -1
  66. package/dist/@vitest/snapshot/{environment.d-DHdQ1Csl.d.ts → environment.d-DOJxxZV9.d.ts} +2 -7
  67. package/dist/@vitest/snapshot/environment.d.ts +2 -1
  68. package/dist/@vitest/snapshot/environment.js +1 -1
  69. package/dist/@vitest/snapshot/index.d.ts +4 -3
  70. package/dist/@vitest/snapshot/index.js +21 -550
  71. package/dist/@vitest/snapshot/manager.d.ts +3 -2
  72. package/dist/@vitest/snapshot/manager.js +1 -1
  73. package/dist/@vitest/snapshot/{rawSnapshot.d-lFsMJFUd.d.ts → rawSnapshot.d-U2kJUxDr.d.ts} +1 -1
  74. package/dist/@vitest/spy/index.d.ts +34 -4
  75. package/dist/@vitest/spy/index.js +69 -19
  76. package/dist/@vitest/utils/diff.js +11 -9
  77. package/dist/@vitest/utils/display.d.ts +2 -1
  78. package/dist/@vitest/utils/display.js +38 -5
  79. package/dist/@vitest/utils/error.d.ts +2 -1
  80. package/dist/@vitest/utils/error.js +1 -2
  81. package/dist/@vitest/utils/helpers.d.ts +4 -1
  82. package/dist/@vitest/utils/helpers.js +43 -1
  83. package/dist/@vitest/utils/resolver.js +1 -2
  84. package/dist/@vitest/utils/serialize.js +6 -6
  85. package/dist/@vitest/utils/source-map/node.d.ts +6 -0
  86. package/dist/@vitest/utils/source-map/node.js +23 -0
  87. package/dist/@vitest/utils/source-map.js +15 -5
  88. package/dist/browser.d.ts +3 -2
  89. package/dist/browser.js +2 -2
  90. package/dist/chunks/acorn.B2iPLyUM.js +5958 -0
  91. package/dist/chunks/{base.CJ0Y4ePK.js → base.DM0-RqVb.js} +54 -16
  92. package/dist/chunks/{benchmark.B3N2zMcH.js → benchmark.D0SlKNbZ.js} +1 -1
  93. package/dist/chunks/{browser.d.ChKACdzH.d.ts → browser.d.X3SXoOCV.d.ts} +4 -1
  94. package/dist/chunks/{cac.DVeoLl0M.js → cac.CWGDZnXT.js} +979 -20
  95. package/dist/chunks/{cli-api.B7PN_QUv.js → cli-api.DuT9iuvY.js} +8764 -7898
  96. package/dist/chunks/{config.d.Cy95HiCx.d.ts → config.d.EJLVE3es.d.ts} +30 -15
  97. package/dist/chunks/{console.Cf-YriPC.js → console.3WNpx0tS.js} +3 -2
  98. package/dist/chunks/{constants.D_Q9UYh-.js → constants.CPYnjOGj.js} +4 -2
  99. package/dist/chunks/coverage.Bri33R1t.js +1050 -0
  100. package/dist/chunks/{creator.DAmOKTvJ.js → creator.DgVhQm5q.js} +35 -4
  101. package/dist/chunks/{defaults.BOqNVLsY.js → defaults.CdU2lD-q.js} +4 -3
  102. package/dist/chunks/{global.d.B15mdLcR.d.ts → global.d.x-ILCfAE.d.ts} +1 -2
  103. package/dist/chunks/{globals.DOayXfHP.js → globals.BXNGLnTL.js} +11 -10
  104. package/dist/chunks/{coverage.AVPTjMgw.js → index.BCY_7LL2.js} +5 -959
  105. package/dist/chunks/{index.C5r1PdPD.js → index.CEzQDJGb.js} +1 -1
  106. package/dist/chunks/{index.D3XRDfWc.js → index.CMESou6r.js} +26 -1
  107. package/dist/chunks/{index.6Qv1eEA6.js → index.DGNSnENe.js} +95 -9
  108. package/dist/chunks/{index.M8mOzt4Y.js → index.DXMFO5MJ.js} +3279 -2914
  109. package/dist/chunks/{index.Z5E_ObnR.js → index.DlDSLQD3.js} +7 -3
  110. package/dist/chunks/{index.CyBMJtT7.js → index.EY6TCHpo.js} +10 -8
  111. package/dist/chunks/{index.D4KonVSU.js → index.og1WyBLx.js} +18 -3
  112. package/dist/chunks/{init-forks._y3TW739.js → init-forks.DeArv0jT.js} +1 -1
  113. package/dist/chunks/{init-threads.DBO2kn-p.js → init-threads.-2OUl4Nn.js} +1 -1
  114. package/dist/chunks/{init.B6MLFIaN.js → init.DICorXCo.js} +52 -13
  115. package/dist/chunks/native.DPzPHdi5.js +148 -0
  116. package/dist/chunks/nativeModuleMocker.DndvSdL6.js +206 -0
  117. package/dist/chunks/nativeModuleRunner.BIakptoF.js +36 -0
  118. package/dist/chunks/{node.Ce0vMQM7.js → node.COQbm6gK.js} +1 -1
  119. package/dist/chunks/{plugin.d.CtqpEehP.d.ts → plugin.d.BuW-flqo.d.ts} +1 -1
  120. package/dist/chunks/{reporters.d.CWXNI2jG.d.ts → reporters.d.DVUYHHhe.d.ts} +328 -79
  121. package/dist/chunks/rpc.MzXet3jl.js +144 -0
  122. package/dist/chunks/{rpc.d.RH3apGEf.d.ts → rpc.d.BFMWpdph.d.ts} +10 -2
  123. package/dist/chunks/{setup-common.Cm-kSBVi.js → setup-common.B41N_kPE.js} +3 -3
  124. package/dist/chunks/{startModuleRunner.DEj0jb3e.js → startVitestModuleRunner.C3ZR-4J3.js} +265 -405
  125. package/dist/chunks/{suite.d.BJWk38HB.d.ts → suite.d.udJtyAgw.d.ts} +1 -1
  126. package/dist/chunks/{vi.2VT5v0um.js → test.CTcmp4Su.js} +538 -181
  127. package/dist/chunks/{utils.DvEY5TfP.js → utils.BX5Fg8C4.js} +8 -1
  128. package/dist/chunks/{vm.D3epNOPZ.js → vm.Dh2rTtmP.js} +48 -8
  129. package/dist/chunks/{worker.d.Dyxm8DEL.d.ts → worker.d.B84sVRy0.d.ts} +2 -2
  130. package/dist/cli.js +6 -5
  131. package/dist/client/.vite/manifest.json +6 -6
  132. package/dist/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
  133. package/dist/client/__vitest__/assets/index-Di71CKDo.js +63 -0
  134. package/dist/client/__vitest__/favicon.ico +0 -0
  135. package/dist/client/__vitest__/favicon.svg +49 -4
  136. package/dist/client/__vitest__/index.html +2 -2
  137. package/dist/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
  138. package/dist/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +167 -58
  139. package/dist/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
  140. package/dist/client/favicon.svg +49 -4
  141. package/dist/client/orchestrator.html +2 -2
  142. package/dist/client/tester/tester.html +2 -2
  143. package/dist/client.js +20 -13
  144. package/dist/config.cjs +3 -2
  145. package/dist/config.d.ts +13 -12
  146. package/dist/config.js +2 -2
  147. package/dist/context.js +108 -22
  148. package/dist/coverage.d.ts +12 -8
  149. package/dist/coverage.js +8 -5
  150. package/dist/environments.js +3 -1
  151. package/dist/expect-element.js +23 -23
  152. package/dist/index-5Pe7X7sp.js +7 -0
  153. package/dist/index.d.ts +66 -27
  154. package/dist/index.js +10 -9
  155. package/dist/locators.d.ts +14 -3
  156. package/dist/locators.js +1 -1
  157. package/dist/module-evaluator.d.ts +11 -1
  158. package/dist/module-evaluator.js +43 -26
  159. package/dist/node.d.ts +28 -14
  160. package/dist/node.js +42 -40
  161. package/dist/nodejs-worker-loader.js +41 -0
  162. package/dist/plugins/mocker-transforms.mjs +2 -0
  163. package/dist/plugins/utils-source-map-node.mjs +2 -0
  164. package/dist/reporters.d.ts +8 -8
  165. package/dist/reporters.js +7 -5
  166. package/dist/runners.d.ts +24 -5
  167. package/dist/runners.js +6 -6
  168. package/dist/runtime.d.ts +6 -0
  169. package/dist/runtime.js +35 -0
  170. package/dist/snapshot.js +4 -2
  171. package/dist/suite.d.ts +1 -1
  172. package/dist/suite.js +4 -2
  173. package/dist/vendor/blazediff_core.d.mts +1 -0
  174. package/dist/vendor/blazediff_core.mjs +117 -0
  175. package/dist/vendor/chai.mjs +4 -249
  176. package/dist/vendor/convert-source-map.d.mts +1 -0
  177. package/dist/vendor/convert-source-map.mjs +150 -0
  178. package/dist/vendor/expect-type.d.mts +14 -7
  179. package/dist/vendor/expect-type.mjs +5 -5
  180. package/dist/vendor/std-env.d.mts +131 -40
  181. package/dist/vendor/std-env.mjs +114 -117
  182. package/dist/worker.d.ts +6 -6
  183. package/dist/worker.js +27 -21
  184. package/dist/workers/forks.js +23 -17
  185. package/dist/workers/runVmTests.js +18 -16
  186. package/dist/workers/threads.js +23 -17
  187. package/dist/workers/vmForks.js +15 -12
  188. package/dist/workers/vmThreads.js +15 -12
  189. package/globals.d.ts +2 -0
  190. package/package.json +35 -26
  191. package/suppress-warnings.cjs +1 -0
  192. package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +0 -57
  193. package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
  194. package/dist/@vitest/browser/index-D6m36C6U.js +0 -11
  195. package/dist/@vitest/utils/chunk-_commonjsHelpers.js +0 -5
  196. package/dist/@vitest/utils/highlight.d.ts +0 -9
  197. package/dist/@vitest/utils/highlight.js +0 -538
  198. package/dist/chunks/date.Bq6ZW5rf.js +0 -73
  199. package/dist/chunks/rpc.BoxB0q7B.js +0 -76
  200. package/dist/chunks/test.B8ej_ZHS.js +0 -254
  201. package/dist/client/__vitest__/assets/index-BUCFJtth.js +0 -57
  202. package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
  203. package/dist/index-D6m36C6U.js +0 -6
  204. package/dist/mocker.d.ts +0 -1
  205. package/dist/mocker.js +0 -1
  206. package/dist/module-runner.js +0 -17
@@ -1,5 +1,5 @@
1
1
  import { SerializedConfig } from '../../index.js'
2
- import { StringifyOptions, BrowserCommands } from '../../browser.js'
2
+ import { StringifyOptions, CDPSession, BrowserCommands } from '../../browser.js'
3
3
  import { ARIARole } from './aria-role.js'
4
4
  import {} from './matchers.js'
5
5
 
@@ -17,11 +17,12 @@ export type BufferEncoding =
17
17
  | 'binary'
18
18
  | 'hex'
19
19
 
20
- export interface CDPSession {
21
- // methods are defined by the provider type augmentation
22
- }
20
+ export { CDPSession };
23
21
 
24
- export interface ScreenshotOptions {
22
+ export interface ScreenshotOptions extends SelectorOptions {
23
+ /**
24
+ * The HTML element to screeshot.
25
+ */
25
26
  element?: Element | Locator
26
27
  /**
27
28
  * Path relative to the current test file.
@@ -40,6 +41,14 @@ export interface ScreenshotOptions {
40
41
  save?: boolean
41
42
  }
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
+
43
52
  interface StandardScreenshotComparators {
44
53
  pixelmatch: {
45
54
  /**
@@ -157,7 +166,7 @@ export interface ScreenshotMatcherOptions<
157
166
  comparatorOptions?: ScreenshotComparatorRegistry[ComparatorName]
158
167
  screenshotOptions?: Omit<
159
168
  ScreenshotOptions,
160
- 'element' | 'base64' | 'path' | 'save' | 'type'
169
+ 'element' | 'base64' | 'path' | 'save' | 'type' | 'strict' | 'timeout'
161
170
  >
162
171
  /**
163
172
  * Time to wait until a stable screenshot is found.
@@ -168,6 +177,13 @@ export interface ScreenshotMatcherOptions<
168
177
  * @default 5000
169
178
  */
170
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
171
187
  }
172
188
 
173
189
  export interface UserEvent {
@@ -207,6 +223,25 @@ export interface UserEvent {
207
223
  * @see {@link https://testing-library.com/docs/user-event/convenience/#tripleclick} testing-library API
208
224
  */
209
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>
210
245
  /**
211
246
  * Choose one or more values from a select element. Uses provider's API under the hood.
212
247
  * If select doesn't have `multiple` attribute, only the first value will be selected.
@@ -345,6 +380,58 @@ export interface UserEventTripleClickOptions {}
345
380
  export interface UserEventDragAndDropOptions {}
346
381
  export interface UserEventUploadOptions {}
347
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
+
348
435
  export interface LocatorOptions {
349
436
  /**
350
437
  * Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a
@@ -408,7 +495,7 @@ export interface LocatorByRoleOptions extends LocatorOptions {
408
495
  selected?: boolean
409
496
  }
410
497
 
411
- interface LocatorScreenshotOptions extends Omit<ScreenshotOptions, 'element'> {}
498
+ export interface LocatorScreenshotOptions extends Omit<ScreenshotOptions, 'element'> {}
412
499
 
413
500
  export interface LocatorSelectors {
414
501
  /**
@@ -443,7 +530,7 @@ export interface LocatorSelectors {
443
530
  */
444
531
  getByTitle: (text: string | RegExp, options?: LocatorOptions) => Locator
445
532
  /**
446
- * 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`](/config/#browser-locators-testidattribute).
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).
447
534
  * @see {@link https://vitest.dev/api/browser/locators#getbytestid}
448
535
  */
449
536
  getByTestId: (text: string | RegExp) => Locator
@@ -451,6 +538,22 @@ export interface LocatorSelectors {
451
538
 
452
539
  export interface FrameLocator extends LocatorSelectors {}
453
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
+
454
557
  export interface Locator extends LocatorSelectors {
455
558
  /**
456
559
  * Selector string that will be used to locate the element by the browser provider.
@@ -489,6 +592,24 @@ export interface Locator extends LocatorSelectors {
489
592
  * @see {@link https://vitest.dev/api/browser/interactivity#userevent-tripleclick}
490
593
  */
491
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>
492
613
  /**
493
614
  * Clears the input element content
494
615
  * @see {@link https://vitest.dev/api/browser/interactivity#userevent-clear}
@@ -538,6 +659,12 @@ export interface Locator extends LocatorSelectors {
538
659
  }>
539
660
  screenshot(options?: LocatorScreenshotOptions): Promise<string>
540
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
+
541
668
  /**
542
669
  * Returns an element matching the selector.
543
670
  *
@@ -600,13 +727,27 @@ export interface Locator extends LocatorSelectors {
600
727
  * @see {@link https://vitest.dev/api/browser/locators#filter}
601
728
  */
602
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>
603
744
  }
604
745
 
605
746
  export interface UserEventTabOptions {
606
747
  shift?: boolean
607
748
  }
608
749
 
609
- export interface UserEventTypeOptions {
750
+ export interface UserEventTypeOptions extends SelectorOptions {
610
751
  skipClick?: boolean
611
752
  skipAutoClose?: boolean
612
753
  }
@@ -687,6 +828,16 @@ export interface BrowserPage extends LocatorSelectors {
687
828
  path: string
688
829
  base64: string
689
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>
690
841
  /**
691
842
  * Extend default `page` object with custom methods.
692
843
  */
@@ -777,7 +928,6 @@ export const utils: {
777
928
  /**
778
929
  * Configures default options of `prettyDOM` and `debug` functions.
779
930
  * This will also affect `vitest-browser-{framework}` package.
780
- * @experimental
781
931
  */
782
932
  configurePrettyDOM(options: StringifyOptions): void
783
933
  /**
@@ -23,9 +23,11 @@ function ensureAwaited(promise) {
23
23
  return (promiseResult ||= promise(sourceError)).then(onFulfilled, onRejected);
24
24
  },
25
25
  catch(onRejected) {
26
+ awaited = true;
26
27
  return (promiseResult ||= promise(sourceError)).catch(onRejected);
27
28
  },
28
29
  finally(onFinally) {
30
+ awaited = true;
29
31
  return (promiseResult ||= promise(sourceError)).finally(onFinally);
30
32
  },
31
33
  [Symbol.toStringTag]: "Promise"
@@ -46,7 +48,6 @@ function getWorkerState() {
46
48
  return state;
47
49
  }
48
50
 
49
- const provider$1 = getBrowserState().provider;
50
51
  /* @__NO_SIDE_EFFECTS__ */
51
52
  function convertElementToCssSelector(element) {
52
53
  if (!element || !(element instanceof Element)) {
@@ -119,9 +120,9 @@ function getParent(el) {
119
120
  }
120
121
  return parent;
121
122
  }
122
- const now = Date.now;
123
+ const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
123
124
  function processTimeoutOptions(options_) {
124
- if (options_ && options_.timeout != null || provider$1 !== "playwright") {
125
+ if (options_ && options_.timeout != null) {
125
126
  return options_;
126
127
  }
127
128
  // if there is a default action timeout, use it
@@ -141,7 +142,7 @@ function processTimeoutOptions(options_) {
141
142
  options_ = options_ || {};
142
143
  const currentTime = now();
143
144
  const endTime = startTime + timeout;
144
- const remainingTime = endTime - currentTime;
145
+ const remainingTime = Math.floor(endTime - currentTime);
145
146
  if (remainingTime <= 0) {
146
147
  return options_;
147
148
  }
@@ -149,7 +150,9 @@ function processTimeoutOptions(options_) {
149
150
  options_.timeout = remainingTime - 100;
150
151
  return options_;
151
152
  }
152
- function convertToSelector(elementOrLocator) {
153
+ const provider$1 = getBrowserState().provider;
154
+ const kElementLocator = Symbol.for("$$vitest:locator-resolved");
155
+ async function convertToSelector(elementOrLocator, options) {
153
156
  if (!elementOrLocator) {
154
157
  throw new Error("Expected element or locator to be defined.");
155
158
  }
@@ -157,7 +160,11 @@ function convertToSelector(elementOrLocator) {
157
160
  return convertElementToCssSelector(elementOrLocator);
158
161
  }
159
162
  if (isLocator(elementOrLocator)) {
160
- return elementOrLocator.selector;
163
+ if (provider$1 === "playwright" || kElementLocator in elementOrLocator) {
164
+ return elementOrLocator.selector;
165
+ }
166
+ const element = await elementOrLocator.findElement(options);
167
+ return convertElementToCssSelector(element);
161
168
  }
162
169
  throw new Error("Expected element or locator to be an instance of Element or Locator.");
163
170
  }
@@ -165,6 +172,36 @@ const kLocator = Symbol.for("$$vitest:locator");
165
172
  function isLocator(element) {
166
173
  return !!element && typeof element === "object" && kLocator in element;
167
174
  }
175
+ const DEFAULT_WHEEL_DELTA = 100;
176
+ function resolveUserEventWheelOptions(options) {
177
+ let delta;
178
+ if (options.delta) {
179
+ delta = options.delta;
180
+ } else {
181
+ switch (options.direction) {
182
+ case "up": {
183
+ delta = { y: -DEFAULT_WHEEL_DELTA };
184
+ break;
185
+ }
186
+ case "down": {
187
+ delta = { y: DEFAULT_WHEEL_DELTA };
188
+ break;
189
+ }
190
+ case "left": {
191
+ delta = { x: -DEFAULT_WHEEL_DELTA };
192
+ break;
193
+ }
194
+ case "right": {
195
+ delta = { x: DEFAULT_WHEEL_DELTA };
196
+ break;
197
+ }
198
+ }
199
+ }
200
+ return {
201
+ delta,
202
+ times: options.times
203
+ };
204
+ }
168
205
 
169
206
  // this file should not import anything directly, only types and utils
170
207
  // @ts-expect-error not typed global
@@ -186,10 +223,10 @@ function createUserEvent(__tl_user_event_base__, options) {
186
223
  setup() {
187
224
  return createUserEvent();
188
225
  },
189
- async cleanup() {
226
+ cleanup() {
190
227
  // avoid cleanup rpc call if there is nothing to cleanup
191
228
  if (!keyboard.unreleased.length) {
192
- return;
229
+ return Promise.resolve();
193
230
  }
194
231
  return ensureAwaited(async (error) => {
195
232
  await triggerCommand("__vitest_cleanup", [keyboard], error);
@@ -205,6 +242,9 @@ function createUserEvent(__tl_user_event_base__, options) {
205
242
  tripleClick(element, options) {
206
243
  return convertToLocator(element).tripleClick(options);
207
244
  },
245
+ wheel(elementOrOptions, options) {
246
+ return convertToLocator(elementOrOptions).wheel(options);
247
+ },
208
248
  selectOptions(element, value, options) {
209
249
  return convertToLocator(element).selectOptions(value, options);
210
250
  },
@@ -228,9 +268,9 @@ function createUserEvent(__tl_user_event_base__, options) {
228
268
  const targetLocator = convertToLocator(target);
229
269
  return sourceLocator.dropTo(targetLocator, options);
230
270
  },
231
- async type(element, text, options) {
271
+ type(element, text, options) {
232
272
  return ensureAwaited(async (error) => {
233
- const selector = convertToSelector(element);
273
+ const selector = await convertToSelector(element, options);
234
274
  const { unreleased } = await triggerCommand("__vitest_type", [
235
275
  selector,
236
276
  text,
@@ -245,20 +285,20 @@ function createUserEvent(__tl_user_event_base__, options) {
245
285
  tab(options = {}) {
246
286
  return ensureAwaited((error) => triggerCommand("__vitest_tab", [options], error));
247
287
  },
248
- async keyboard(text) {
288
+ keyboard(text) {
249
289
  return ensureAwaited(async (error) => {
250
290
  const { unreleased } = await triggerCommand("__vitest_keyboard", [text, keyboard], error);
251
291
  keyboard.unreleased = unreleased;
252
292
  });
253
293
  },
254
- async copy() {
255
- await userEvent.keyboard(`{${modifier}>}{c}{/${modifier}}`);
294
+ copy() {
295
+ return userEvent.keyboard(`{${modifier}>}{c}{/${modifier}}`);
256
296
  },
257
- async cut() {
258
- await userEvent.keyboard(`{${modifier}>}{x}{/${modifier}}`);
297
+ cut() {
298
+ return userEvent.keyboard(`{${modifier}>}{x}{/${modifier}}`);
259
299
  },
260
- async paste() {
261
- await userEvent.keyboard(`{${modifier}>}{v}{/${modifier}}`);
300
+ paste() {
301
+ return userEvent.keyboard(`{${modifier}>}{v}{/${modifier}}`);
262
302
  }
263
303
  };
264
304
  return userEvent;
@@ -339,6 +379,26 @@ function createPreviewUserEvent(userEventBase, options) {
339
379
  },
340
380
  async paste() {
341
381
  await userEvent.paste(clipboardData);
382
+ },
383
+ async wheel(element, options) {
384
+ const resolvedElement = isLocator(element) ? element.element() : element;
385
+ const resolvedOptions = resolveUserEventWheelOptions(options);
386
+ const rect = resolvedElement.getBoundingClientRect();
387
+ const centerX = rect.left + rect.width / 2;
388
+ const centerY = rect.top + rect.height / 2;
389
+ const wheelEvent = new WheelEvent("wheel", {
390
+ clientX: centerX,
391
+ clientY: centerY,
392
+ deltaY: resolvedOptions.delta.y ?? 0,
393
+ deltaX: resolvedOptions.delta.x ?? 0,
394
+ deltaMode: 0,
395
+ bubbles: true,
396
+ cancelable: true
397
+ });
398
+ const times = options.times ?? 1;
399
+ for (let count = 0; count < times; count += 1) {
400
+ resolvedElement.dispatchEvent(wheelEvent);
401
+ }
342
402
  }
343
403
  };
344
404
  for (const [name, fn] of Object.entries(vitestUserEvent)) {
@@ -390,18 +450,47 @@ const page = {
390
450
  screenshotIds[repeatCount] ??= {};
391
451
  screenshotIds[repeatCount][taskName] = number + 1;
392
452
  const name = options.path || `${taskName.replace(/[^a-z0-9]/gi, "-")}-${number}.png`;
453
+ const [element, ...mask] = await Promise.all([options.element ? convertToSelector(options.element, options) : undefined, ..."mask" in options ? options.mask.map((el) => convertToSelector(el, options)) : []]);
393
454
  const normalizedOptions = "mask" in options ? {
394
455
  ...options,
395
- mask: options.mask.map(convertToSelector)
456
+ mask
396
457
  } : options;
397
458
  return ensureAwaited((error) => triggerCommand("__vitest_screenshot", [name, processTimeoutOptions(
398
459
  {
399
460
  ...normalizedOptions,
400
- element: options.element ? convertToSelector(options.element) : undefined
461
+ element
401
462
  }
402
463
  /** TODO */
403
464
  )], error));
404
465
  },
466
+ mark(name, bodyOrOptions, options) {
467
+ const currentTest = getWorkerState().current;
468
+ const hasActiveTrace = !!currentTest && getBrowserState().activeTraceTaskIds.has(currentTest.id);
469
+ if (typeof bodyOrOptions === "function") {
470
+ return ensureAwaited(async (error) => {
471
+ if (hasActiveTrace) {
472
+ await triggerCommand("__vitest_groupTraceStart", [{
473
+ name,
474
+ stack: options?.stack ?? error?.stack
475
+ }], error);
476
+ }
477
+ try {
478
+ return await bodyOrOptions();
479
+ } finally {
480
+ if (hasActiveTrace) {
481
+ await triggerCommand("__vitest_groupTraceEnd", [], error);
482
+ }
483
+ }
484
+ });
485
+ }
486
+ if (!hasActiveTrace) {
487
+ return Promise.resolve();
488
+ }
489
+ return ensureAwaited((error) => triggerCommand("__vitest_markTrace", [{
490
+ name,
491
+ stack: bodyOrOptions?.stack ?? error?.stack
492
+ }], error));
493
+ },
405
494
  getByRole() {
406
495
  throw new Error(`Method "getByRole" is not supported by the "${provider}" provider.`);
407
496
  },
@@ -524,9 +613,6 @@ function getElementError(selector, container) {
524
613
  error.name = "VitestBrowserElementError";
525
614
  return error;
526
615
  }
527
- /**
528
- * @experimental
529
- */
530
616
  function configurePrettyDOM(options) {
531
617
  defaultOptions = options;
532
618
  }