@voidzero-dev/vite-plus-test 0.0.0-0bfcc90f.20260209-0731

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 (318) hide show
  1. package/LICENSE.md +691 -0
  2. package/browser/context.d.ts +4 -0
  3. package/browser/context.js +20 -0
  4. package/config.d.ts +3 -0
  5. package/coverage.d.ts +1 -0
  6. package/dist/@vitest/browser/client/.vite/manifest.json +24 -0
  7. package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +57 -0
  8. package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
  9. package/dist/@vitest/browser/client/__vitest__/bg.png +0 -0
  10. package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
  11. package/dist/@vitest/browser/client/__vitest__/favicon.svg +5 -0
  12. package/dist/@vitest/browser/client/__vitest__/index.html +32 -0
  13. package/dist/@vitest/browser/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
  14. package/dist/@vitest/browser/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
  15. package/dist/@vitest/browser/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
  16. package/dist/@vitest/browser/client/error-catcher.js +82 -0
  17. package/dist/@vitest/browser/client/esm-client-injector.js +67 -0
  18. package/dist/@vitest/browser/client/favicon.svg +5 -0
  19. package/dist/@vitest/browser/client/orchestrator.html +35 -0
  20. package/dist/@vitest/browser/client/tester/tester.html +13 -0
  21. package/dist/@vitest/browser/client.js +456 -0
  22. package/dist/@vitest/browser/context.d.ts +792 -0
  23. package/dist/@vitest/browser/context.js +541 -0
  24. package/dist/@vitest/browser/expect-element.js +32 -0
  25. package/dist/@vitest/browser/index-D6m36C6U.js +11 -0
  26. package/dist/@vitest/browser/index.d.ts +73 -0
  27. package/dist/@vitest/browser/index.js +3513 -0
  28. package/dist/@vitest/browser/jest-dom.d.ts +724 -0
  29. package/dist/@vitest/browser/locators.d.ts +354 -0
  30. package/dist/@vitest/browser/locators.js +1 -0
  31. package/dist/@vitest/browser/matchers.d.ts +29 -0
  32. package/dist/@vitest/browser/shared/screenshotMatcher/types.d.ts +22 -0
  33. package/dist/@vitest/browser/state.js +280 -0
  34. package/dist/@vitest/browser/types.d.ts +69 -0
  35. package/dist/@vitest/browser-playwright/context.d.ts +1 -0
  36. package/dist/@vitest/browser-playwright/index.d.ts +106 -0
  37. package/dist/@vitest/browser-playwright/index.js +1111 -0
  38. package/dist/@vitest/browser-playwright/locators.js +114 -0
  39. package/dist/@vitest/browser-preview/context.d.ts +1 -0
  40. package/dist/@vitest/browser-preview/index.d.ts +19 -0
  41. package/dist/@vitest/browser-preview/index.js +148 -0
  42. package/dist/@vitest/browser-preview/locators.js +79 -0
  43. package/dist/@vitest/browser-webdriverio/context.d.ts +1 -0
  44. package/dist/@vitest/browser-webdriverio/index.d.ts +63 -0
  45. package/dist/@vitest/browser-webdriverio/index.js +600 -0
  46. package/dist/@vitest/browser-webdriverio/locators.js +163 -0
  47. package/dist/@vitest/expect/index.d.ts +807 -0
  48. package/dist/@vitest/expect/index.js +1875 -0
  49. package/dist/@vitest/mocker/auto-register.d.ts +2 -0
  50. package/dist/@vitest/mocker/auto-register.js +9 -0
  51. package/dist/@vitest/mocker/automock.d.ts +12 -0
  52. package/dist/@vitest/mocker/automock.js +1 -0
  53. package/dist/@vitest/mocker/browser.d.ts +53 -0
  54. package/dist/@vitest/mocker/browser.js +91 -0
  55. package/dist/@vitest/mocker/chunk-automock.js +354 -0
  56. package/dist/@vitest/mocker/chunk-interceptor-native.js +15 -0
  57. package/dist/@vitest/mocker/chunk-mocker.js +521 -0
  58. package/dist/@vitest/mocker/chunk-pathe.M-eThtNZ.js +174 -0
  59. package/dist/@vitest/mocker/chunk-registry.js +185 -0
  60. package/dist/@vitest/mocker/chunk-utils.js +16 -0
  61. package/dist/@vitest/mocker/index.d-C-sLYZi-.d.ts +25 -0
  62. package/dist/@vitest/mocker/index.d.ts +2 -0
  63. package/dist/@vitest/mocker/index.js +185 -0
  64. package/dist/@vitest/mocker/mocker.d-TnKRhz7N.d.ts +81 -0
  65. package/dist/@vitest/mocker/node.d.ts +800 -0
  66. package/dist/@vitest/mocker/node.js +966 -0
  67. package/dist/@vitest/mocker/redirect.d.ts +3 -0
  68. package/dist/@vitest/mocker/redirect.js +79 -0
  69. package/dist/@vitest/mocker/register.d.ts +9 -0
  70. package/dist/@vitest/mocker/register.js +41 -0
  71. package/dist/@vitest/mocker/types.d-B8CCKmHt.d.ts +107 -0
  72. package/dist/@vitest/pretty-format/index.d.ts +124 -0
  73. package/dist/@vitest/pretty-format/index.js +1022 -0
  74. package/dist/@vitest/runner/chunk-tasks.js +340 -0
  75. package/dist/@vitest/runner/index.d.ts +180 -0
  76. package/dist/@vitest/runner/index.js +2114 -0
  77. package/dist/@vitest/runner/tasks.d-C7UxawJ9.d.ts +834 -0
  78. package/dist/@vitest/runner/types.d.ts +183 -0
  79. package/dist/@vitest/runner/types.js +1 -0
  80. package/dist/@vitest/runner/utils.d.ts +45 -0
  81. package/dist/@vitest/runner/utils.js +5 -0
  82. package/dist/@vitest/snapshot/environment.d-DHdQ1Csl.d.ts +22 -0
  83. package/dist/@vitest/snapshot/environment.d.ts +16 -0
  84. package/dist/@vitest/snapshot/environment.js +40 -0
  85. package/dist/@vitest/snapshot/index.d.ts +130 -0
  86. package/dist/@vitest/snapshot/index.js +1437 -0
  87. package/dist/@vitest/snapshot/manager.d.ts +18 -0
  88. package/dist/@vitest/snapshot/manager.js +73 -0
  89. package/dist/@vitest/snapshot/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
  90. package/dist/@vitest/spy/index.d.ts +384 -0
  91. package/dist/@vitest/spy/index.js +433 -0
  92. package/dist/@vitest/utils/chunk-_commonjsHelpers.js +5 -0
  93. package/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js +156 -0
  94. package/dist/@vitest/utils/constants.d.ts +21 -0
  95. package/dist/@vitest/utils/constants.js +49 -0
  96. package/dist/@vitest/utils/diff.d.ts +93 -0
  97. package/dist/@vitest/utils/diff.js +2199 -0
  98. package/dist/@vitest/utils/display.d.ts +29 -0
  99. package/dist/@vitest/utils/display.js +742 -0
  100. package/dist/@vitest/utils/error.d.ts +7 -0
  101. package/dist/@vitest/utils/error.js +42 -0
  102. package/dist/@vitest/utils/helpers.d.ts +73 -0
  103. package/dist/@vitest/utils/helpers.js +295 -0
  104. package/dist/@vitest/utils/highlight.d.ts +9 -0
  105. package/dist/@vitest/utils/highlight.js +538 -0
  106. package/dist/@vitest/utils/index.d.ts +5 -0
  107. package/dist/@vitest/utils/index.js +1 -0
  108. package/dist/@vitest/utils/offset.d.ts +5 -0
  109. package/dist/@vitest/utils/offset.js +32 -0
  110. package/dist/@vitest/utils/resolver.d.ts +7 -0
  111. package/dist/@vitest/utils/resolver.js +71 -0
  112. package/dist/@vitest/utils/serialize.d.ts +3 -0
  113. package/dist/@vitest/utils/serialize.js +118 -0
  114. package/dist/@vitest/utils/source-map.d.ts +55 -0
  115. package/dist/@vitest/utils/source-map.js +478 -0
  116. package/dist/@vitest/utils/timers.d.ts +33 -0
  117. package/dist/@vitest/utils/timers.js +49 -0
  118. package/dist/@vitest/utils/types.d-BCElaP-c.d.ts +53 -0
  119. package/dist/@vitest/utils/types.d.ts +34 -0
  120. package/dist/@vitest/utils/types.js +1 -0
  121. package/dist/browser-compat.js +3 -0
  122. package/dist/browser.d.ts +46 -0
  123. package/dist/browser.js +20 -0
  124. package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
  125. package/dist/chunks/base.CJ0Y4ePK.js +165 -0
  126. package/dist/chunks/benchmark.B3N2zMcH.js +40 -0
  127. package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +24 -0
  128. package/dist/chunks/browser.d.ChKACdzH.d.ts +59 -0
  129. package/dist/chunks/cac.DVeoLl0M.js +1409 -0
  130. package/dist/chunks/cli-api.B7PN_QUv.js +13672 -0
  131. package/dist/chunks/config.d.Cy95HiCx.d.ts +210 -0
  132. package/dist/chunks/console.Cf-YriPC.js +146 -0
  133. package/dist/chunks/constants.D_Q9UYh-.js +36 -0
  134. package/dist/chunks/coverage.AVPTjMgw.js +3292 -0
  135. package/dist/chunks/coverage.D_JHT54q.js +25 -0
  136. package/dist/chunks/coverage.d.BZtK59WP.d.ts +37 -0
  137. package/dist/chunks/creator.DAmOKTvJ.js +673 -0
  138. package/dist/chunks/date.Bq6ZW5rf.js +73 -0
  139. package/dist/chunks/defaults.BOqNVLsY.js +74 -0
  140. package/dist/chunks/env.D4Lgay0q.js +8 -0
  141. package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
  142. package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
  143. package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
  144. package/dist/chunks/git.Bm2pzPAa.js +71 -0
  145. package/dist/chunks/global.d.B15mdLcR.d.ts +99 -0
  146. package/dist/chunks/globals.DOayXfHP.js +30 -0
  147. package/dist/chunks/index.6Qv1eEA6.js +109 -0
  148. package/dist/chunks/index.C5r1PdPD.js +231 -0
  149. package/dist/chunks/index.Chj8NDwU.js +206 -0
  150. package/dist/chunks/index.CyBMJtT7.js +727 -0
  151. package/dist/chunks/index.D3XRDfWc.js +213 -0
  152. package/dist/chunks/index.D4KonVSU.js +6343 -0
  153. package/dist/chunks/index.M8mOzt4Y.js +3839 -0
  154. package/dist/chunks/index.Z5E_ObnR.js +37 -0
  155. package/dist/chunks/init-forks._y3TW739.js +41 -0
  156. package/dist/chunks/init-threads.DBO2kn-p.js +18 -0
  157. package/dist/chunks/init.B6MLFIaN.js +334 -0
  158. package/dist/chunks/inspector.CvyFGlXm.js +53 -0
  159. package/dist/chunks/modules.BJuCwlRJ.js +36 -0
  160. package/dist/chunks/node.Ce0vMQM7.js +14 -0
  161. package/dist/chunks/plugin.d.CtqpEehP.d.ts +38 -0
  162. package/dist/chunks/reporters.d.CWXNI2jG.d.ts +3271 -0
  163. package/dist/chunks/rpc.BoxB0q7B.js +76 -0
  164. package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
  165. package/dist/chunks/setup-common.Cm-kSBVi.js +60 -0
  166. package/dist/chunks/startModuleRunner.DEj0jb3e.js +861 -0
  167. package/dist/chunks/suite.d.BJWk38HB.d.ts +10 -0
  168. package/dist/chunks/test.B8ej_ZHS.js +254 -0
  169. package/dist/chunks/traces.CCmnQaNT.js +217 -0
  170. package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
  171. package/dist/chunks/utils.DvEY5TfP.js +52 -0
  172. package/dist/chunks/vi.2VT5v0um.js +3919 -0
  173. package/dist/chunks/vm.D3epNOPZ.js +744 -0
  174. package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
  175. package/dist/cli.js +28 -0
  176. package/dist/client/.vite/manifest.json +24 -0
  177. package/dist/client/__vitest__/assets/index-BUCFJtth.js +57 -0
  178. package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
  179. package/dist/client/__vitest__/bg.png +0 -0
  180. package/dist/client/__vitest__/favicon.ico +0 -0
  181. package/dist/client/__vitest__/favicon.svg +5 -0
  182. package/dist/client/__vitest__/index.html +32 -0
  183. package/dist/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
  184. package/dist/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
  185. package/dist/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
  186. package/dist/client/error-catcher.js +82 -0
  187. package/dist/client/esm-client-injector.js +67 -0
  188. package/dist/client/favicon.svg +5 -0
  189. package/dist/client/orchestrator.html +35 -0
  190. package/dist/client/tester/tester.html +13 -0
  191. package/dist/client.js +456 -0
  192. package/dist/config.cjs +94 -0
  193. package/dist/config.d.ts +104 -0
  194. package/dist/config.js +15 -0
  195. package/dist/context.js +541 -0
  196. package/dist/coverage.d.ts +118 -0
  197. package/dist/coverage.js +23 -0
  198. package/dist/dummy.js +2 -0
  199. package/dist/environments.d.ts +22 -0
  200. package/dist/environments.js +3 -0
  201. package/dist/expect-element.js +27 -0
  202. package/dist/index-D6m36C6U.js +6 -0
  203. package/dist/index-node.js +7 -0
  204. package/dist/index.d.ts +510 -0
  205. package/dist/index.js +19 -0
  206. package/dist/locators.d.ts +354 -0
  207. package/dist/locators.js +1 -0
  208. package/dist/mocker.d.ts +1 -0
  209. package/dist/mocker.js +1 -0
  210. package/dist/module-evaluator.d.ts +124 -0
  211. package/dist/module-evaluator.js +343 -0
  212. package/dist/module-runner-stub.js +44 -0
  213. package/dist/module-runner.js +17 -0
  214. package/dist/node.d.ts +251 -0
  215. package/dist/node.js +98 -0
  216. package/dist/path.js +7 -0
  217. package/dist/plugins/browser-client.mjs +2 -0
  218. package/dist/plugins/browser-context.mjs +2 -0
  219. package/dist/plugins/browser-locators.mjs +2 -0
  220. package/dist/plugins/browser-playwright.mjs +2 -0
  221. package/dist/plugins/browser-preview.mjs +2 -0
  222. package/dist/plugins/browser-webdriverio.mjs +2 -0
  223. package/dist/plugins/browser.mjs +2 -0
  224. package/dist/plugins/expect.mjs +2 -0
  225. package/dist/plugins/mocker-automock.mjs +2 -0
  226. package/dist/plugins/mocker-browser.mjs +2 -0
  227. package/dist/plugins/mocker-node.mjs +2 -0
  228. package/dist/plugins/mocker-redirect.mjs +2 -0
  229. package/dist/plugins/mocker-register.mjs +2 -0
  230. package/dist/plugins/mocker.mjs +2 -0
  231. package/dist/plugins/pretty-format.mjs +2 -0
  232. package/dist/plugins/runner-types.mjs +2 -0
  233. package/dist/plugins/runner-utils.mjs +2 -0
  234. package/dist/plugins/runner.mjs +2 -0
  235. package/dist/plugins/snapshot-environment.mjs +2 -0
  236. package/dist/plugins/snapshot-manager.mjs +2 -0
  237. package/dist/plugins/snapshot.mjs +2 -0
  238. package/dist/plugins/spy.mjs +2 -0
  239. package/dist/plugins/utils-constants.mjs +2 -0
  240. package/dist/plugins/utils-diff.mjs +2 -0
  241. package/dist/plugins/utils-display.mjs +2 -0
  242. package/dist/plugins/utils-error.mjs +2 -0
  243. package/dist/plugins/utils-helpers.mjs +2 -0
  244. package/dist/plugins/utils-highlight.mjs +2 -0
  245. package/dist/plugins/utils-offset.mjs +2 -0
  246. package/dist/plugins/utils-resolver.mjs +2 -0
  247. package/dist/plugins/utils-serialize.mjs +2 -0
  248. package/dist/plugins/utils-source-map.mjs +2 -0
  249. package/dist/plugins/utils-timers.mjs +2 -0
  250. package/dist/plugins/utils.mjs +2 -0
  251. package/dist/reporters.d.ts +27 -0
  252. package/dist/reporters.js +24 -0
  253. package/dist/runners.d.ts +50 -0
  254. package/dist/runners.js +19 -0
  255. package/dist/shared/screenshotMatcher/types.d.ts +22 -0
  256. package/dist/snapshot.d.ts +9 -0
  257. package/dist/snapshot.js +4 -0
  258. package/dist/spy.js +1 -0
  259. package/dist/state.js +280 -0
  260. package/dist/suite.d.ts +5 -0
  261. package/dist/suite.js +6 -0
  262. package/dist/types.d.ts +69 -0
  263. package/dist/vendor/chai.d.mts +1 -0
  264. package/dist/vendor/chai.mjs +3577 -0
  265. package/dist/vendor/es-module-lexer.d.mts +193 -0
  266. package/dist/vendor/es-module-lexer.mjs +79 -0
  267. package/dist/vendor/estree-walker.d.mts +583 -0
  268. package/dist/vendor/estree-walker.mjs +339 -0
  269. package/dist/vendor/expect-type.d.mts +1574 -0
  270. package/dist/vendor/expect-type.mjs +214 -0
  271. package/dist/vendor/magic-string.d.mts +261 -0
  272. package/dist/vendor/magic-string.mjs +1700 -0
  273. package/dist/vendor/obug.d.mts +56 -0
  274. package/dist/vendor/obug.mjs +276 -0
  275. package/dist/vendor/pathe.d.mts +46 -0
  276. package/dist/vendor/pathe.mjs +496 -0
  277. package/dist/vendor/picomatch.d.mts +1 -0
  278. package/dist/vendor/picomatch.mjs +1855 -0
  279. package/dist/vendor/shared-3g9mwCWP.mjs +31 -0
  280. package/dist/vendor/std-env.d.mts +88 -0
  281. package/dist/vendor/std-env.mjs +159 -0
  282. package/dist/vendor/tinybench.d.mts +317 -0
  283. package/dist/vendor/tinybench.mjs +504 -0
  284. package/dist/vendor/tinyexec.d.mts +72 -0
  285. package/dist/vendor/tinyexec.mjs +637 -0
  286. package/dist/vendor/tinyglobby.d.mts +157 -0
  287. package/dist/vendor/tinyglobby.mjs +832 -0
  288. package/dist/vendor/tinyrainbow.d.mts +60 -0
  289. package/dist/vendor/tinyrainbow.mjs +93 -0
  290. package/dist/vendor/vitest_browser.mjs +2 -0
  291. package/dist/vendor/vitest_internal_browser.mjs +2 -0
  292. package/dist/vendor/vitest_runner.mjs +2 -0
  293. package/dist/vendor/vitest_runners.mjs +2 -0
  294. package/dist/worker.d.ts +32 -0
  295. package/dist/worker.js +48 -0
  296. package/dist/workers/forks.js +54 -0
  297. package/dist/workers/runVmTests.js +95 -0
  298. package/dist/workers/threads.js +55 -0
  299. package/dist/workers/vmForks.js +36 -0
  300. package/dist/workers/vmThreads.js +37 -0
  301. package/environments.d.ts +1 -0
  302. package/globals.d.ts +20 -0
  303. package/import-meta.d.ts +5 -0
  304. package/importMeta.d.ts +4 -0
  305. package/index.cjs +5 -0
  306. package/index.d.cts +1 -0
  307. package/jsdom.d.ts +6 -0
  308. package/mocker.d.ts +1 -0
  309. package/node.d.ts +1 -0
  310. package/optional-types.d.ts +7 -0
  311. package/package.json +335 -0
  312. package/reporters.d.ts +1 -0
  313. package/runners.d.ts +1 -0
  314. package/snapshot.d.ts +1 -0
  315. package/suite.d.ts +1 -0
  316. package/suppress-warnings.cjs +21 -0
  317. package/vitest.mjs +2 -0
  318. package/worker.d.ts +1 -0
@@ -0,0 +1,792 @@
1
+ import { SerializedConfig } from '../../index.js'
2
+ import { StringifyOptions, BrowserCommands } from '../../browser.js'
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 interface CDPSession {
21
+ // methods are defined by the provider type augmentation
22
+ }
23
+
24
+ export interface ScreenshotOptions {
25
+ element?: Element | Locator
26
+ /**
27
+ * Path relative to the current test file.
28
+ * @default `__screenshots__/${testFileName}/${testName}.png`
29
+ */
30
+ path?: string
31
+ /**
32
+ * Will also return the base64 encoded screenshot alongside the path.
33
+ */
34
+ base64?: boolean
35
+ /**
36
+ * Keep the screenshot on the file system. If file is not saved,
37
+ * `page.screenshot` always returns `base64` screenshot.
38
+ * @default true
39
+ */
40
+ save?: boolean
41
+ }
42
+
43
+ interface StandardScreenshotComparators {
44
+ pixelmatch: {
45
+ /**
46
+ * The maximum number of pixels that are allowed to differ between the captured
47
+ * screenshot and the stored reference image.
48
+ *
49
+ * If set to `undefined`, any non-zero difference will cause the test to fail.
50
+ *
51
+ * For example, `allowedMismatchedPixels: 10` means the test will pass if 10
52
+ * or fewer pixels differ, but fail if 11 or more differ.
53
+ *
54
+ * If both this and `allowedMismatchedPixelRatio` are set, the more restrictive
55
+ * value (i.e., fewer allowed mismatches) will be used.
56
+ *
57
+ * @default undefined
58
+ */
59
+ allowedMismatchedPixels?: number | undefined
60
+ /**
61
+ * The maximum allowed ratio of differing pixels between the captured screenshot
62
+ * and the reference image.
63
+ *
64
+ * Must be a value between `0` and `1`.
65
+ *
66
+ * For example, `allowedMismatchedPixelRatio: 0.02` means the test will pass
67
+ * if up to 2% of pixels differ, but fail if more than 2% differ.
68
+ *
69
+ * If both this and `allowedMismatchedPixels` are set, the more restrictive
70
+ * value (i.e., fewer allowed mismatches) will be used.
71
+ *
72
+ * @default undefined
73
+ */
74
+ allowedMismatchedPixelRatio?: number | undefined
75
+ /**
76
+ * Acceptable perceived color difference between the same pixel in two images.
77
+ *
78
+ * Value ranges from `0` (strict) to `1` (very lenient). Lower values mean
79
+ * small differences will be detected.
80
+ *
81
+ * The comparison uses the {@link https://en.wikipedia.org/wiki/YIQ | YIQ color space}.
82
+ *
83
+ * @default 0.1
84
+ */
85
+ threshold?: number | undefined
86
+ /**
87
+ * If `true`, disables detection and ignoring of anti-aliased pixels.
88
+ *
89
+ * @default false
90
+ */
91
+ includeAA?: boolean | undefined
92
+ /**
93
+ * Blending level of unchanged pixels in the diff image.
94
+ *
95
+ * Ranges from `0` (white) to `1` (original brightness).
96
+ *
97
+ * @default 0.1
98
+ */
99
+ alpha?: number | undefined
100
+ /**
101
+ * Color used for anti-aliased pixels in the diff image.
102
+ *
103
+ * Format: `[R, G, B]`
104
+ *
105
+ * @default [255, 255, 0]
106
+ */
107
+ aaColor?: [r: number, g: number, b: number] | undefined
108
+ /**
109
+ * Color used for differing pixels in the diff image.
110
+ *
111
+ * Format: `[R, G, B]`
112
+ *
113
+ * @default [255, 0, 0]
114
+ */
115
+ diffColor?: [r: number, g: number, b: number] | undefined
116
+ /**
117
+ * Optional alternative color for dark-on-light differences, to help show
118
+ * what's added vs. removed.
119
+ *
120
+ * If not set, `diffColor` is used for all differences.
121
+ *
122
+ * Format: `[R, G, B]`
123
+ *
124
+ * @default undefined
125
+ */
126
+ diffColorAlt?: [r: number, g: number, b: number] | undefined
127
+ /**
128
+ * If `true`, shows only the diff as a mask on a transparent background,
129
+ * instead of overlaying it on the original image.
130
+ *
131
+ * Anti-aliased pixels won't be shown (if detected).
132
+ *
133
+ * @default false
134
+ */
135
+ diffMask?: boolean | undefined
136
+ }
137
+ }
138
+
139
+ export interface ScreenshotComparatorRegistry extends StandardScreenshotComparators {}
140
+
141
+ export type NonStandardScreenshotComparators = Omit<
142
+ ScreenshotComparatorRegistry,
143
+ keyof StandardScreenshotComparators
144
+ >
145
+
146
+ export interface ScreenshotMatcherOptions<
147
+ ComparatorName extends keyof ScreenshotComparatorRegistry = keyof ScreenshotComparatorRegistry
148
+ > {
149
+ /**
150
+ * The name of the comparator to use for visual diffing.
151
+ *
152
+ * Must be one of the keys from {@linkcode ScreenshotComparatorRegistry}.
153
+ *
154
+ * @defaultValue `'pixelmatch'`
155
+ */
156
+ comparatorName?: ComparatorName
157
+ comparatorOptions?: ScreenshotComparatorRegistry[ComparatorName]
158
+ screenshotOptions?: Omit<
159
+ ScreenshotOptions,
160
+ 'element' | 'base64' | 'path' | 'save' | 'type'
161
+ >
162
+ /**
163
+ * Time to wait until a stable screenshot is found.
164
+ *
165
+ * Setting this value to `0` disables the timeout, but if a stable screenshot
166
+ * can't be determined the process will not end.
167
+ *
168
+ * @default 5000
169
+ */
170
+ timeout?: number
171
+ }
172
+
173
+ export interface UserEvent {
174
+ /**
175
+ * Creates a new user event instance. This is useful if you need to keep the
176
+ * state of keyboard to press and release buttons correctly.
177
+ *
178
+ * **Note:** Unlike `@testing-library/user-event`, the default `userEvent` instance
179
+ * from `vitest/browser` is created once, not every time its methods are called!
180
+ * @see {@link https://vitest.dev/api/browser/interactivity.html#userevent-setup}
181
+ */
182
+ setup: () => UserEvent
183
+ /**
184
+ * Cleans up the user event instance, releasing any resources or state it holds,
185
+ * such as keyboard press state. For the default `userEvent` instance, this method
186
+ * is automatically called after each test case.
187
+ */
188
+ cleanup: () => Promise<void>
189
+ /**
190
+ * Click on an element. Uses provider's API under the hood and supports all its options.
191
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-click} Playwright API
192
+ * @see {@link https://webdriver.io/docs/api/element/click/} WebdriverIO API
193
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#click} testing-library API
194
+ */
195
+ click: (element: Element | Locator, options?: UserEventClickOptions) => Promise<void>
196
+ /**
197
+ * Triggers a double click event on an element. Uses provider's API under the hood.
198
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-dblclick} Playwright API
199
+ * @see {@link https://webdriver.io/docs/api/element/doubleClick/} WebdriverIO API
200
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#dblClick} testing-library API
201
+ */
202
+ dblClick: (element: Element | Locator, options?: UserEventDoubleClickOptions) => Promise<void>
203
+ /**
204
+ * Triggers a triple click event on an element. Uses provider's API under the hood.
205
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-click} Playwright API: using `click` with `clickCount: 3`
206
+ * @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
207
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#tripleclick} testing-library API
208
+ */
209
+ tripleClick: (element: Element | Locator, options?: UserEventTripleClickOptions) => Promise<void>
210
+ /**
211
+ * Choose one or more values from a select element. Uses provider's API under the hood.
212
+ * If select doesn't have `multiple` attribute, only the first value will be selected.
213
+ * @example
214
+ * await userEvent.selectOptions(select, 'Option 1')
215
+ * expect(select).toHaveValue('option-1')
216
+ *
217
+ * await userEvent.selectOptions(select, 'option-1')
218
+ * expect(select).toHaveValue('option-1')
219
+ *
220
+ * await userEvent.selectOptions(select, [
221
+ * screen.getByRole('option', { name: 'Option 1' }),
222
+ * screen.getByRole('option', { name: 'Option 2' }),
223
+ * ])
224
+ * expect(select).toHaveValue(['option-1', 'option-2'])
225
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-select-option} Playwright API
226
+ * @see {@link https://webdriver.io/docs/api/element/doubleClick/} WebdriverIO API
227
+ * @see {@link https://testing-library.com/docs/user-event/utility/#-selectoptions-deselectoptions} testing-library API
228
+ */
229
+ selectOptions: (
230
+ element: HTMLElement | SVGElement | Locator,
231
+ values: HTMLElement | HTMLElement[] | Locator | Locator[] | string | string[],
232
+ options?: UserEventSelectOptions,
233
+ ) => Promise<void>
234
+ /**
235
+ * Type text on the keyboard. If any input is focused, it will receive the text,
236
+ * otherwise it will be typed on the document. Uses provider's API under the hood.
237
+ * **Supports** [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard) (e.g., `{Shift}`) even with `playwright` and `webdriverio` providers.
238
+ * @example
239
+ * await userEvent.keyboard('foo') // translates to: f, o, o
240
+ * await userEvent.keyboard('{{a[[') // translates to: {, a, [
241
+ * await userEvent.keyboard('{Shift}{f}{o}{o}') // translates to: Shift, f, o, o
242
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
243
+ * @see {@link https://webdriver.io/docs/api/browser/keys} WebdriverIO API
244
+ * @see {@link https://testing-library.com/docs/user-event/keyboard} testing-library API
245
+ */
246
+ keyboard: (text: string) => Promise<void>
247
+ /**
248
+ * Types text into an element. Uses provider's API under the hood.
249
+ * **Supports** [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard) (e.g., `{Shift}`) even with `playwright` and `webdriverio` providers.
250
+ * This method can be significantly slower than `userEvent.fill`, so it should be used only when necessary.
251
+ * @example
252
+ * await userEvent.type(input, 'foo') // translates to: f, o, o
253
+ * await userEvent.type(input, '{{a[[') // translates to: {, a, [
254
+ * await userEvent.type(input, '{Shift}{f}{o}{o}') // translates to: Shift, f, o, o
255
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-press} Playwright API
256
+ * @see {@link https://webdriver.io/docs/api/browser/action#key-input-source} WebdriverIO API
257
+ * @see {@link https://testing-library.com/docs/user-event/utility/#type} testing-library API
258
+ */
259
+ type: (element: Element | Locator, text: string, options?: UserEventTypeOptions) => Promise<void>
260
+ /**
261
+ * Removes all text from an element. Uses provider's API under the hood.
262
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-clear} Playwright API
263
+ * @see {@link https://webdriver.io/docs/api/element/clearValue} WebdriverIO API
264
+ * @see {@link https://testing-library.com/docs/user-event/utility/#clear} testing-library API
265
+ */
266
+ clear: (element: Element | Locator, options?: UserEventClearOptions) => Promise<void>
267
+ /**
268
+ * Sends a `Tab` key event. Uses provider's API under the hood.
269
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
270
+ * @see {@link https://webdriver.io/docs/api/element/keys} WebdriverIO API
271
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#tab} testing-library API
272
+ */
273
+ tab: (options?: UserEventTabOptions) => Promise<void>
274
+ /**
275
+ * Hovers over an element. Uses provider's API under the hood.
276
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-hover} Playwright API
277
+ * @see {@link https://webdriver.io/docs/api/element/moveTo/} WebdriverIO API
278
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#hover} testing-library API
279
+ */
280
+ hover: (element: Element | Locator, options?: UserEventHoverOptions) => Promise<void>
281
+ /**
282
+ * Moves cursor position to the body element. Uses provider's API under the hood.
283
+ * By default, the cursor position is in the center (in webdriverio) or in some visible place (in playwright)
284
+ * of the body element, so if the current element is already there, this will have no effect.
285
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-hover} Playwright API
286
+ * @see {@link https://webdriver.io/docs/api/element/moveTo/} WebdriverIO API
287
+ * @see {@link https://testing-library.com/docs/user-event/convenience/#hover} testing-library API
288
+ */
289
+ unhover: (element: Element | Locator, options?: UserEventHoverOptions) => Promise<void>
290
+ /**
291
+ * Change a file input element to have the specified files. Uses provider's API under the hood.
292
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-set-input-files} Playwright API
293
+ * @see {@link https://testing-library.com/docs/user-event/utility#upload} testing-library API
294
+ */
295
+ upload: (element: Element | Locator, files: File | File[] | string | string[], options?: UserEventUploadOptions) => Promise<void>
296
+ /**
297
+ * Copies the selected content.
298
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
299
+ * @see {@link https://webdriver.io/docs/api/browser/keys//} WebdriverIO API
300
+ * @see {@link https://testing-library.com/docs/user-event/clipboard#copy} testing-library API
301
+ */
302
+ copy: () => Promise<void>
303
+ /**
304
+ * Cuts the selected content.
305
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
306
+ * @see {@link https://webdriver.io/docs/api/browser/keys//} WebdriverIO API
307
+ * @see {@link https://testing-library.com/docs/user-event/clipboard#cut} testing-library API
308
+ */
309
+ cut: () => Promise<void>
310
+ /**
311
+ * Pastes the copied or cut content.
312
+ * @see {@link https://playwright.dev/docs/api/class-keyboard} Playwright API
313
+ * @see {@link https://webdriver.io/docs/api/browser/keys//} WebdriverIO API
314
+ * @see {@link https://testing-library.com/docs/user-event/clipboard#paste} testing-library API
315
+ */
316
+ paste: () => Promise<void>
317
+ /**
318
+ * Fills an input element with text. This will remove any existing text in the input before typing the new text.
319
+ * Uses provider's API under the hood.
320
+ * 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}`).
321
+ * @example
322
+ * await userEvent.fill(input, 'foo') // translates to: f, o, o
323
+ * await userEvent.fill(input, '{{a[[') // translates to: {, {, a, [, [
324
+ * await userEvent.fill(input, '{Shift}') // translates to: {, S, h, i, f, t, }
325
+ * @see {@link https://playwright.dev/docs/api/class-locator#locator-fill} Playwright API
326
+ * @see {@link https://webdriver.io/docs/api/element/setValue} WebdriverIO API
327
+ * @see {@link https://testing-library.com/docs/user-event/utility/#type} testing-library API
328
+ */
329
+ fill: (element: Element | Locator, text: string, options?: UserEventFillOptions) => Promise<void>
330
+ /**
331
+ * Drags a source element on top of the target element. This API is not supported by "preview" provider.
332
+ * @see {@link https://playwright.dev/docs/api/class-frame#frame-drag-and-drop} Playwright API
333
+ * @see {@link https://webdriver.io/docs/api/element/dragAndDrop/} WebdriverIO API
334
+ */
335
+ dragAndDrop: (source: Element | Locator, target: Element | Locator, options?: UserEventDragAndDropOptions) => Promise<void>
336
+ }
337
+
338
+ export interface UserEventFillOptions {}
339
+ export interface UserEventHoverOptions {}
340
+ export interface UserEventSelectOptions {}
341
+ export interface UserEventClickOptions {}
342
+ export interface UserEventClearOptions {}
343
+ export interface UserEventDoubleClickOptions {}
344
+ export interface UserEventTripleClickOptions {}
345
+ export interface UserEventDragAndDropOptions {}
346
+ export interface UserEventUploadOptions {}
347
+
348
+ export interface LocatorOptions {
349
+ /**
350
+ * Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a
351
+ * regular expression. Note that exact match still trims whitespace.
352
+ */
353
+ exact?: boolean
354
+ hasText?: string | RegExp
355
+ hasNotText?: string | RegExp
356
+ has?: Locator
357
+ hasNot?: Locator
358
+ }
359
+
360
+ export interface LocatorByRoleOptions extends LocatorOptions {
361
+ /**
362
+ * Should checked elements (set by `aria-checked` or `<input type="checkbox"/>`) be included or not. By default, the filter is not applied.
363
+ *
364
+ * See [`aria-checked`](https://www.w3.org/TR/wai-aria-1.2/#aria-checked) for more information
365
+ */
366
+ checked?: boolean
367
+ /**
368
+ * Should disabled elements be included or not. By default, the filter is not applied. Note that unlike other attributes, `disable` state is inherited.
369
+ *
370
+ * See [`aria-disabled`](https://www.w3.org/TR/wai-aria-1.2/#aria-disabled) for more information
371
+ */
372
+ disabled?: boolean
373
+ /**
374
+ * Should expanded elements be included or not. By default, the filter is not applied.
375
+ *
376
+ * See [`aria-expanded`](https://www.w3.org/TR/wai-aria-1.2/#aria-expanded) for more information
377
+ */
378
+ expanded?: boolean
379
+ /**
380
+ * 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.
381
+ *
382
+ * Note that roles `none` and `presentation` are always included.
383
+ * @default false
384
+ */
385
+ includeHidden?: boolean
386
+ /**
387
+ * 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.
388
+ *
389
+ * See [`aria-level`](https://www.w3.org/TR/wai-aria-1.2/#aria-level) for more information
390
+ */
391
+ level?: number
392
+ /**
393
+ * Option to match the [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). By default, matching is
394
+ * case-insensitive and searches for a substring, use `exact` to control this behavior.
395
+ */
396
+ name?: string | RegExp
397
+ /**
398
+ * Should pressed elements be included or not. By default, the filter is not applied.
399
+ *
400
+ * See [`aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed) for more information
401
+ */
402
+ pressed?: boolean
403
+ /**
404
+ * Should selected elements be included or not. By default, the filter is not applied.
405
+ *
406
+ * See [`aria-selected`](https://www.w3.org/TR/wai-aria-1.2/#aria-selected) for more information
407
+ */
408
+ selected?: boolean
409
+ }
410
+
411
+ interface LocatorScreenshotOptions extends Omit<ScreenshotOptions, 'element'> {}
412
+
413
+ export interface LocatorSelectors {
414
+ /**
415
+ * 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).
416
+ * @see {@link https://vitest.dev/api/browser/locators#getbyrole}
417
+ */
418
+ getByRole: (role: ARIARole | ({} & string), options?: LocatorByRoleOptions) => Locator
419
+ /**
420
+ * @see {@link https://vitest.dev/api/browser/locators#getbylabeltext}
421
+ */
422
+ getByLabelText: (text: string | RegExp, options?: LocatorOptions) => Locator
423
+ /**
424
+ * 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.
425
+ * @see {@link https://vitest.dev/api/browser/locators#getbyalttext}
426
+ */
427
+ getByAltText: (text: string | RegExp, options?: LocatorOptions) => Locator
428
+ /**
429
+ * 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`.
430
+ * @see {@link https://vitest.dev/api/browser/locators#getbyplaceholder}
431
+ */
432
+ getByPlaceholder: (text: string | RegExp, options?: LocatorOptions) => Locator
433
+ /**
434
+ * 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`.
435
+ * Matching by text always normalizes whitespace, even with exact match.
436
+ * For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
437
+ * @see {@link https://vitest.dev/api/browser/locators#getbytext}
438
+ */
439
+ getByText: (text: string | RegExp, options?: LocatorOptions) => Locator
440
+ /**
441
+ * 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.
442
+ * @see {@link https://vitest.dev/api/browser/locators#getbytitle}
443
+ */
444
+ getByTitle: (text: string | RegExp, options?: LocatorOptions) => Locator
445
+ /**
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).
447
+ * @see {@link https://vitest.dev/api/browser/locators#getbytestid}
448
+ */
449
+ getByTestId: (text: string | RegExp) => Locator
450
+ }
451
+
452
+ export interface FrameLocator extends LocatorSelectors {}
453
+
454
+ export interface Locator extends LocatorSelectors {
455
+ /**
456
+ * Selector string that will be used to locate the element by the browser provider.
457
+ * You can use this string in the commands API:
458
+ * ```ts
459
+ * // playwright
460
+ * function test({ selector, iframe }) {
461
+ * await iframe.locator(selector).click()
462
+ * }
463
+ * // webdriverio
464
+ * function test({ selector, browser }) {
465
+ * await browser.$(selector).click()
466
+ * }
467
+ * ```
468
+ * @see {@link https://vitest.dev/api/browser/locators#selector}
469
+ */
470
+ readonly selector: string
471
+
472
+ /**
473
+ * The number of elements that this locator is matching.
474
+ * @see {@link https://vitest.dev/api/browser/locators#length}
475
+ */
476
+ readonly length: number
477
+
478
+ /**
479
+ * Click on an element. You can use the options to set the cursor position.
480
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-click}
481
+ */
482
+ click(options?: UserEventClickOptions): Promise<void>
483
+ /**
484
+ * Triggers a double click event on an element. You can use the options to set the cursor position.
485
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-dblclick}
486
+ */
487
+ dblClick(options?: UserEventDoubleClickOptions): Promise<void>
488
+ /**
489
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-tripleclick}
490
+ */
491
+ tripleClick(options?: UserEventTripleClickOptions): Promise<void>
492
+ /**
493
+ * Clears the input element content
494
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-clear}
495
+ */
496
+ clear(options?: UserEventClearOptions): Promise<void>
497
+ /**
498
+ * Moves the cursor position to the selected element
499
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-hover}
500
+ */
501
+ hover(options?: UserEventHoverOptions): Promise<void>
502
+ /**
503
+ * This works the same as `locator.hover`, but moves the cursor to the `document.body` element instead.
504
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-unhover}
505
+ */
506
+ unhover(options?: UserEventHoverOptions): Promise<void>
507
+ /**
508
+ * Sets the value of the current `input`, `textarea` or `contenteditable` element.
509
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-fill}
510
+ */
511
+ fill(text: string, options?: UserEventFillOptions): Promise<void>
512
+ /**
513
+ * Drags the current element to the target location.
514
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-dropto}
515
+ */
516
+ dropTo(target: Locator, options?: UserEventDragAndDropOptions): Promise<void>
517
+ /**
518
+ * Choose one or more values from a `<select>` element.
519
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-selectoptions}
520
+ */
521
+ selectOptions(
522
+ values: HTMLElement | HTMLElement[] | Locator | Locator[] | string | string[],
523
+ options?: UserEventSelectOptions,
524
+ ): Promise<void>
525
+ /**
526
+ * Change a file input element to have the specified files. Uses provider's API under the hood.
527
+ * @see {@link https://vitest.dev/api/browser/interactivity#userevent-upload}
528
+ */
529
+ upload(files: File | File[] | string | string[], options?: UserEventUploadOptions): Promise<void>
530
+
531
+ /**
532
+ * Make a screenshot of an element matching the locator.
533
+ * @see {@link https://vitest.dev/api/browser/locators#screenshot}
534
+ */
535
+ screenshot(options: Omit<LocatorScreenshotOptions, 'base64'> & { base64: true }): Promise<{
536
+ path: string
537
+ base64: string
538
+ }>
539
+ screenshot(options?: LocatorScreenshotOptions): Promise<string>
540
+
541
+ /**
542
+ * Returns an element matching the selector.
543
+ *
544
+ * - If multiple elements match the selector, an error is thrown.
545
+ * - If no elements match the selector, an error is thrown.
546
+ *
547
+ * @see {@link https://vitest.dev/api/browser/locators#element}
548
+ */
549
+ element(): HTMLElement | SVGElement
550
+ /**
551
+ * Returns an array of elements matching the selector.
552
+ *
553
+ * If no elements match the selector, an empty array is returned.
554
+ *
555
+ * @see {@link https://vitest.dev/api/browser/locators#elements}
556
+ */
557
+ elements(): (HTMLElement | SVGElement)[]
558
+ /**
559
+ * Returns an element matching the selector.
560
+ *
561
+ * - If multiple elements match the selector, an error is thrown.
562
+ * - If no elements match the selector, returns `null`.
563
+ *
564
+ * @see {@link https://vitest.dev/api/browser/locators#query}
565
+ */
566
+ query(): HTMLElement | SVGElement | null
567
+ /**
568
+ * Wraps an array of `.elements()` matching the selector in a new `Locator`.
569
+ *
570
+ * @see {@link https://vitest.dev/api/browser/locators#all}
571
+ */
572
+ all(): Locator[]
573
+ /**
574
+ * Returns a locator for the nth element matching the selector.
575
+ * @see {@link https://vitest.dev/api/browser/locators#nth}
576
+ */
577
+ nth(index: number): Locator
578
+ /**
579
+ * Returns a locator for the first element matching the selector.
580
+ * @see {@link https://vitest.dev/api/browser/locators#first}
581
+ */
582
+ first(): Locator
583
+ /**
584
+ * Returns a locator for the last element matching the selector.
585
+ * @see {@link https://vitest.dev/api/browser/locators#last}
586
+ */
587
+ last(): Locator
588
+ /**
589
+ * Returns a locator that matches both the current locator and the provided locator.
590
+ * @see {@link https://vitest.dev/api/browser/locators#and}
591
+ */
592
+ and(locator: Locator): Locator
593
+ /**
594
+ * Returns a locator that matches either the current locator or the provided locator.
595
+ * @see {@link https://vitest.dev/api/browser/locators#or}
596
+ */
597
+ or(locator: Locator): Locator
598
+ /**
599
+ * Narrows existing locator according to the options.
600
+ * @see {@link https://vitest.dev/api/browser/locators#filter}
601
+ */
602
+ filter(options: LocatorOptions): Locator
603
+ }
604
+
605
+ export interface UserEventTabOptions {
606
+ shift?: boolean
607
+ }
608
+
609
+ export interface UserEventTypeOptions {
610
+ skipClick?: boolean
611
+ skipAutoClose?: boolean
612
+ }
613
+
614
+ type Platform =
615
+ | 'aix'
616
+ | 'android'
617
+ | 'darwin'
618
+ | 'freebsd'
619
+ | 'haiku'
620
+ | 'linux'
621
+ | 'openbsd'
622
+ | 'sunos'
623
+ | 'win32'
624
+ | 'cygwin'
625
+ | 'netbsd'
626
+
627
+ export const server: {
628
+ /**
629
+ * Platform the Vitest server is running on.
630
+ * The same as calling `process.platform` on the server.
631
+ */
632
+ platform: Platform
633
+ /**
634
+ * Runtime version of the Vitest server.
635
+ * The same as calling `process.version` on the server.
636
+ */
637
+ version: string
638
+ /**
639
+ * Name of the browser provider.
640
+ */
641
+ provider: string
642
+ /**
643
+ * Name of the current browser.
644
+ */
645
+ browser: string
646
+ /**
647
+ * Available commands for the browser.
648
+ * @see {@link https://vitest.dev/api/browser/commands}
649
+ */
650
+ commands: BrowserCommands
651
+ /**
652
+ * Serialized test config.
653
+ */
654
+ config: SerializedConfig
655
+ }
656
+
657
+ /**
658
+ * Handler for user interactions. The support is provided by the browser provider (`playwright` or `webdriverio`).
659
+ * If used with `preview` provider, fallbacks to simulated events via `@testing-library/user-event`.
660
+ * @experimental
661
+ */
662
+ export const userEvent: UserEvent
663
+
664
+ /**
665
+ * Available commands for the browser.
666
+ * A shortcut to `server.commands`.
667
+ * @see {@link https://vitest.dev/api/browser/commands}
668
+ */
669
+ export const commands: BrowserCommands
670
+
671
+ export interface BrowserPage extends LocatorSelectors {
672
+ /**
673
+ * Change the size of iframe's viewport.
674
+ */
675
+ viewport(width: number, height: number): Promise<void>
676
+ /**
677
+ * Make a screenshot of the test iframe or a specific element.
678
+ * @returns Path to the screenshot file or path and base64.
679
+ */
680
+ screenshot(options: Omit<ScreenshotOptions, 'save'> & { save: false }): Promise<string>
681
+ screenshot(options: Omit<ScreenshotOptions, 'base64'> & { base64: true }): Promise<{
682
+ path: string
683
+ base64: string
684
+ }>
685
+ screenshot(options?: Omit<ScreenshotOptions, 'base64'>): Promise<string>
686
+ screenshot(options?: ScreenshotOptions): Promise<string | {
687
+ path: string
688
+ base64: string
689
+ }>
690
+ /**
691
+ * Extend default `page` object with custom methods.
692
+ */
693
+ extend(methods: Partial<BrowserPage>): BrowserPage
694
+ /**
695
+ * Wrap an HTML element in a `Locator`. When querying for elements, the search will always return this element.
696
+ * @see {@link https://vitest.dev/api/browser/locators}
697
+ */
698
+ elementLocator(element: Element): Locator
699
+ /**
700
+ * The iframe locator. This is a document locator that enters the iframe body
701
+ * and works similarly to the `page` object.
702
+ *
703
+ * As the first argument, pass down the locator to the `<iframe>` element itself.
704
+ *
705
+ * **Warning:** At the moment, this is supported only by the `playwright` provider.
706
+ * @example
707
+ * ```ts
708
+ * const frame = page.frameLocator(
709
+ * page.getByTestId('iframe')
710
+ * )
711
+ *
712
+ * await frame.getByText('Hello World').click()
713
+ * ```
714
+ * @param locator The locator object.
715
+ * @see {@link https://vitest.dev/api/browser/locators}
716
+ */
717
+ frameLocator(locator: Locator): FrameLocator
718
+ }
719
+
720
+ export interface BrowserLocators {
721
+ createElementLocators(element: Element): LocatorSelectors
722
+ // TODO: enhance docs
723
+ /**
724
+ * Extends `page.*` and `locator.*` interfaces.
725
+ * @see {@link}
726
+ *
727
+ * @example
728
+ * ```ts
729
+ * import { locators } from 'vitest/browser'
730
+ *
731
+ * declare module 'vitest/browser' {
732
+ * interface LocatorSelectors {
733
+ * getByCSS(css: string): Locator
734
+ * }
735
+ * }
736
+ *
737
+ * locators.extend({
738
+ * getByCSS(css: string) {
739
+ * return `css=${css}`
740
+ * }
741
+ * })
742
+ * ```
743
+ */
744
+ extend(methods: {
745
+ [K in keyof LocatorSelectors]?: (
746
+ this: BrowserPage | Locator,
747
+ ...args: Parameters<LocatorSelectors[K]>
748
+ ) => ReturnType<LocatorSelectors[K]> | string
749
+ }): void
750
+ }
751
+
752
+
753
+ export type PrettyDOMOptions = Omit<StringifyOptions, 'maxLength'>
754
+
755
+ export const utils: {
756
+ /**
757
+ * This is simillar to calling `page.elementLocator`, but it returns only
758
+ * locator selectors.
759
+ */
760
+ getElementLocatorSelectors(element: Element): LocatorSelectors
761
+ /**
762
+ * Prints prettified HTML of an element.
763
+ */
764
+ debug(
765
+ el?: Element | Locator | null | (Element | Locator)[],
766
+ maxLength?: number,
767
+ options?: PrettyDOMOptions,
768
+ ): void
769
+ /**
770
+ * Returns prettified HTML of an element.
771
+ */
772
+ prettyDOM(
773
+ dom?: Element | Locator | undefined | null,
774
+ maxLength?: number,
775
+ prettyFormatOptions?: PrettyDOMOptions,
776
+ ): string
777
+ /**
778
+ * Configures default options of `prettyDOM` and `debug` functions.
779
+ * This will also affect `vitest-browser-{framework}` package.
780
+ * @experimental
781
+ */
782
+ configurePrettyDOM(options: StringifyOptions): void
783
+ /**
784
+ * Creates "Cannot find element" error. Useful for custom locators.
785
+ */
786
+ getElementError(selector: string, container?: Element): Error
787
+ }
788
+
789
+ export const locators: BrowserLocators
790
+
791
+ export const page: BrowserPage
792
+ export const cdp: () => CDPSession