@vitest-agent/mcp 1.1.0 → 1.3.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 (209) hide show
  1. package/README.md +1 -2
  2. package/index.d.ts +3 -2
  3. package/index.js +1 -1
  4. package/package.json +1 -1
  5. package/server.js +2 -4
  6. package/tools/run-tests.js +17 -3
  7. package/patterns/_meta.json +0 -67
  8. package/patterns/authoring-a-custom-vitest-agent-reporter.md +0 -82
  9. package/patterns/known-issues-and-caveats.md +0 -52
  10. package/patterns/operating-vitest-agent-as-an-agent.md +0 -62
  11. package/patterns/running-tests-via-mcp.md +0 -103
  12. package/patterns/silencing-leaking-output-in-tests.md +0 -91
  13. package/patterns/testing-effect-schema-definitions.md +0 -71
  14. package/patterns/testing-effect-services-with-mock-layers.md +0 -63
  15. package/resources/index.js +0 -166
  16. package/resources/indexes.js +0 -77
  17. package/resources/manifest-schema.js +0 -46
  18. package/resources/paths.js +0 -20
  19. package/resources/patterns.js +0 -22
  20. package/resources/upstream-docs.js +0 -22
  21. package/vendor/vitest-docs/ATTRIBUTION.md +0 -5
  22. package/vendor/vitest-docs/api/advanced/artifacts.md +0 -189
  23. package/vendor/vitest-docs/api/advanced/metadata.md +0 -68
  24. package/vendor/vitest-docs/api/advanced/plugin.md +0 -168
  25. package/vendor/vitest-docs/api/advanced/reporters.md +0 -342
  26. package/vendor/vitest-docs/api/advanced/runner.md +0 -334
  27. package/vendor/vitest-docs/api/advanced/test-case.md +0 -302
  28. package/vendor/vitest-docs/api/advanced/test-collection.md +0 -89
  29. package/vendor/vitest-docs/api/advanced/test-module.md +0 -140
  30. package/vendor/vitest-docs/api/advanced/test-project.md +0 -321
  31. package/vendor/vitest-docs/api/advanced/test-specification.md +0 -96
  32. package/vendor/vitest-docs/api/advanced/test-suite.md +0 -230
  33. package/vendor/vitest-docs/api/advanced/vitest.md +0 -684
  34. package/vendor/vitest-docs/api/assert-type.md +0 -22
  35. package/vendor/vitest-docs/api/assert.md +0 -1960
  36. package/vendor/vitest-docs/api/browser/assertions.md +0 -1277
  37. package/vendor/vitest-docs/api/browser/commands.md +0 -154
  38. package/vendor/vitest-docs/api/browser/context.md +0 -338
  39. package/vendor/vitest-docs/api/browser/interactivity.md +0 -681
  40. package/vendor/vitest-docs/api/browser/locators.md +0 -1171
  41. package/vendor/vitest-docs/api/browser/react.md +0 -346
  42. package/vendor/vitest-docs/api/browser/svelte.md +0 -292
  43. package/vendor/vitest-docs/api/browser/vue.md +0 -222
  44. package/vendor/vitest-docs/api/describe.md +0 -374
  45. package/vendor/vitest-docs/api/expect-typeof.md +0 -571
  46. package/vendor/vitest-docs/api/expect.md +0 -2304
  47. package/vendor/vitest-docs/api/hooks.md +0 -463
  48. package/vendor/vitest-docs/api/mock.md +0 -701
  49. package/vendor/vitest-docs/api/test.md +0 -926
  50. package/vendor/vitest-docs/api/vi.md +0 -1372
  51. package/vendor/vitest-docs/config/alias.md +0 -13
  52. package/vendor/vitest-docs/config/allowonly.md +0 -32
  53. package/vendor/vitest-docs/config/api.md +0 -27
  54. package/vendor/vitest-docs/config/attachmentsdir.md +0 -6
  55. package/vendor/vitest-docs/config/bail.md +0 -9
  56. package/vendor/vitest-docs/config/benchmark.md +0 -65
  57. package/vendor/vitest-docs/config/browser/api.md +0 -23
  58. package/vendor/vitest-docs/config/browser/commands.md +0 -6
  59. package/vendor/vitest-docs/config/browser/connecttimeout.md +0 -10
  60. package/vendor/vitest-docs/config/browser/detailspanelposition.md +0 -38
  61. package/vendor/vitest-docs/config/browser/enabled.md +0 -40
  62. package/vendor/vitest-docs/config/browser/expect.md +0 -250
  63. package/vendor/vitest-docs/config/browser/headless.md +0 -7
  64. package/vendor/vitest-docs/config/browser/instances.md +0 -47
  65. package/vendor/vitest-docs/config/browser/isolate.md +0 -11
  66. package/vendor/vitest-docs/config/browser/locators.md +0 -24
  67. package/vendor/vitest-docs/config/browser/orchestratorscripts.md +0 -39
  68. package/vendor/vitest-docs/config/browser/playwright.md +0 -214
  69. package/vendor/vitest-docs/config/browser/preview.md +0 -32
  70. package/vendor/vitest-docs/config/browser/provider.md +0 -79
  71. package/vendor/vitest-docs/config/browser/screenshotdirectory.md +0 -6
  72. package/vendor/vitest-docs/config/browser/screenshotfailures.md +0 -6
  73. package/vendor/vitest-docs/config/browser/testerhtmlpath.md +0 -5
  74. package/vendor/vitest-docs/config/browser/trace.md +0 -43
  75. package/vendor/vitest-docs/config/browser/trackunhandlederrors.md +0 -10
  76. package/vendor/vitest-docs/config/browser/ui.md +0 -7
  77. package/vendor/vitest-docs/config/browser/viewport.md +0 -6
  78. package/vendor/vitest-docs/config/browser/webdriverio.md +0 -64
  79. package/vendor/vitest-docs/config/cache.md +0 -26
  80. package/vendor/vitest-docs/config/chaiconfig.md +0 -29
  81. package/vendor/vitest-docs/config/clearmocks.md +0 -22
  82. package/vendor/vitest-docs/config/coverage.md +0 -455
  83. package/vendor/vitest-docs/config/css.md +0 -47
  84. package/vendor/vitest-docs/config/dangerouslyignoreunhandlederrors.md +0 -23
  85. package/vendor/vitest-docs/config/deps.md +0 -127
  86. package/vendor/vitest-docs/config/detectasyncleaks.md +0 -39
  87. package/vendor/vitest-docs/config/diff.md +0 -96
  88. package/vendor/vitest-docs/config/dir.md +0 -7
  89. package/vendor/vitest-docs/config/disableconsoleintercept.md +0 -15
  90. package/vendor/vitest-docs/config/env.md +0 -5
  91. package/vendor/vitest-docs/config/environment.md +0 -96
  92. package/vendor/vitest-docs/config/environmentoptions.md +0 -30
  93. package/vendor/vitest-docs/config/exclude.md +0 -49
  94. package/vendor/vitest-docs/config/execargv.md +0 -10
  95. package/vendor/vitest-docs/config/expandsnapshotdiff.md +0 -7
  96. package/vendor/vitest-docs/config/expect.md +0 -38
  97. package/vendor/vitest-docs/config/experimental.md +0 -510
  98. package/vendor/vitest-docs/config/faketimers.md +0 -51
  99. package/vendor/vitest-docs/config/fileparallelism.md +0 -11
  100. package/vendor/vitest-docs/config/forcereruntriggers.md +0 -19
  101. package/vendor/vitest-docs/config/globals.md +0 -42
  102. package/vendor/vitest-docs/config/globalsetup.md +0 -72
  103. package/vendor/vitest-docs/config/hideskippedtests.md +0 -7
  104. package/vendor/vitest-docs/config/hooktimeout.md +0 -7
  105. package/vendor/vitest-docs/config/include-source.md +0 -115
  106. package/vendor/vitest-docs/config/include.md +0 -71
  107. package/vendor/vitest-docs/config/includetasklocation.md +0 -17
  108. package/vendor/vitest-docs/config/index.md +0 -85
  109. package/vendor/vitest-docs/config/isolate.md +0 -13
  110. package/vendor/vitest-docs/config/logheapusage.md +0 -7
  111. package/vendor/vitest-docs/config/maxconcurrency.md +0 -9
  112. package/vendor/vitest-docs/config/maxworkers.md +0 -49
  113. package/vendor/vitest-docs/config/mockreset.md +0 -22
  114. package/vendor/vitest-docs/config/mode.md +0 -7
  115. package/vendor/vitest-docs/config/name.md +0 -111
  116. package/vendor/vitest-docs/config/onconsolelog.md +0 -25
  117. package/vendor/vitest-docs/config/onstacktrace.md +0 -32
  118. package/vendor/vitest-docs/config/onunhandlederror.md +0 -35
  119. package/vendor/vitest-docs/config/open.md +0 -7
  120. package/vendor/vitest-docs/config/outputfile.md +0 -7
  121. package/vendor/vitest-docs/config/passwithnotests.md +0 -7
  122. package/vendor/vitest-docs/config/pool.md +0 -45
  123. package/vendor/vitest-docs/config/printconsoletrace.md +0 -6
  124. package/vendor/vitest-docs/config/projects.md +0 -6
  125. package/vendor/vitest-docs/config/provide.md +0 -45
  126. package/vendor/vitest-docs/config/reporters.md +0 -69
  127. package/vendor/vitest-docs/config/resolvesnapshotpath.md +0 -36
  128. package/vendor/vitest-docs/config/restoremocks.md +0 -22
  129. package/vendor/vitest-docs/config/retry.md +0 -140
  130. package/vendor/vitest-docs/config/root.md +0 -6
  131. package/vendor/vitest-docs/config/runner.md +0 -6
  132. package/vendor/vitest-docs/config/sequence.md +0 -158
  133. package/vendor/vitest-docs/config/server.md +0 -68
  134. package/vendor/vitest-docs/config/setupfiles.md +0 -40
  135. package/vendor/vitest-docs/config/silent.md +0 -9
  136. package/vendor/vitest-docs/config/slowtestthreshold.md +0 -7
  137. package/vendor/vitest-docs/config/snapshotenvironment.md +0 -27
  138. package/vendor/vitest-docs/config/snapshotformat.md +0 -28
  139. package/vendor/vitest-docs/config/snapshotserializers.md +0 -6
  140. package/vendor/vitest-docs/config/stricttags.md +0 -30
  141. package/vendor/vitest-docs/config/tags.md +0 -141
  142. package/vendor/vitest-docs/config/teardowntimeout.md +0 -7
  143. package/vendor/vitest-docs/config/testnamepattern.md +0 -21
  144. package/vendor/vitest-docs/config/testtimeout.md +0 -7
  145. package/vendor/vitest-docs/config/typecheck.md +0 -77
  146. package/vendor/vitest-docs/config/ui.md +0 -15
  147. package/vendor/vitest-docs/config/unstubenvs.md +0 -20
  148. package/vendor/vitest-docs/config/unstubglobals.md +0 -20
  149. package/vendor/vitest-docs/config/update.md +0 -16
  150. package/vendor/vitest-docs/config/vmmemorylimit.md +0 -30
  151. package/vendor/vitest-docs/config/watch.md +0 -11
  152. package/vendor/vitest-docs/config/watchtriggerpatterns.md +0 -29
  153. package/vendor/vitest-docs/guide/advanced/index.md +0 -147
  154. package/vendor/vitest-docs/guide/advanced/pool.md +0 -148
  155. package/vendor/vitest-docs/guide/advanced/reporters.md +0 -93
  156. package/vendor/vitest-docs/guide/advanced/tests.md +0 -125
  157. package/vendor/vitest-docs/guide/browser/aria-snapshots.md +0 -470
  158. package/vendor/vitest-docs/guide/browser/component-testing.md +0 -571
  159. package/vendor/vitest-docs/guide/browser/index.md +0 -630
  160. package/vendor/vitest-docs/guide/browser/multiple-setups.md +0 -121
  161. package/vendor/vitest-docs/guide/browser/trace-view.md +0 -126
  162. package/vendor/vitest-docs/guide/browser/visual-regression-testing.md +0 -734
  163. package/vendor/vitest-docs/guide/cli-generated.md +0 -972
  164. package/vendor/vitest-docs/guide/cli.md +0 -234
  165. package/vendor/vitest-docs/guide/common-errors.md +0 -163
  166. package/vendor/vitest-docs/guide/coverage.md +0 -515
  167. package/vendor/vitest-docs/guide/debugging.md +0 -127
  168. package/vendor/vitest-docs/guide/environment.md +0 -101
  169. package/vendor/vitest-docs/guide/extending-matchers.md +0 -160
  170. package/vendor/vitest-docs/guide/features.md +0 -310
  171. package/vendor/vitest-docs/guide/filtering.md +0 -175
  172. package/vendor/vitest-docs/guide/ide.md +0 -43
  173. package/vendor/vitest-docs/guide/improving-performance.md +0 -245
  174. package/vendor/vitest-docs/guide/in-source.md +0 -159
  175. package/vendor/vitest-docs/guide/index.md +0 -128
  176. package/vendor/vitest-docs/guide/learn/async.md +0 -147
  177. package/vendor/vitest-docs/guide/learn/debugging-tests.md +0 -210
  178. package/vendor/vitest-docs/guide/learn/matchers.md +0 -277
  179. package/vendor/vitest-docs/guide/learn/mock-functions.md +0 -277
  180. package/vendor/vitest-docs/guide/learn/setup-teardown.md +0 -240
  181. package/vendor/vitest-docs/guide/learn/snapshots.md +0 -166
  182. package/vendor/vitest-docs/guide/learn/testing-in-practice.md +0 -430
  183. package/vendor/vitest-docs/guide/learn/writing-tests-with-ai.md +0 -127
  184. package/vendor/vitest-docs/guide/learn/writing-tests.md +0 -231
  185. package/vendor/vitest-docs/guide/lifecycle.md +0 -379
  186. package/vendor/vitest-docs/guide/migration.md +0 -863
  187. package/vendor/vitest-docs/guide/mocking/classes.md +0 -158
  188. package/vendor/vitest-docs/guide/mocking/dates.md +0 -52
  189. package/vendor/vitest-docs/guide/mocking/file-system.md +0 -74
  190. package/vendor/vitest-docs/guide/mocking/functions.md +0 -61
  191. package/vendor/vitest-docs/guide/mocking/globals.md +0 -20
  192. package/vendor/vitest-docs/guide/mocking/modules.md +0 -414
  193. package/vendor/vitest-docs/guide/mocking/requests.md +0 -114
  194. package/vendor/vitest-docs/guide/mocking/timers.md +0 -48
  195. package/vendor/vitest-docs/guide/mocking.md +0 -239
  196. package/vendor/vitest-docs/guide/open-telemetry.md +0 -156
  197. package/vendor/vitest-docs/guide/parallelism.md +0 -82
  198. package/vendor/vitest-docs/guide/profiling-test-performance.md +0 -243
  199. package/vendor/vitest-docs/guide/projects.md +0 -291
  200. package/vendor/vitest-docs/guide/recipes.md +0 -59
  201. package/vendor/vitest-docs/guide/reporters.md +0 -723
  202. package/vendor/vitest-docs/guide/snapshot.md +0 -620
  203. package/vendor/vitest-docs/guide/test-annotations.md +0 -103
  204. package/vendor/vitest-docs/guide/test-context.md +0 -902
  205. package/vendor/vitest-docs/guide/test-tags.md +0 -314
  206. package/vendor/vitest-docs/guide/testing-types.md +0 -149
  207. package/vendor/vitest-docs/guide/ui.md +0 -160
  208. package/vendor/vitest-docs/guide/using-plugins.md +0 -5
  209. package/vendor/vitest-docs/manifest.json +0 -1691
@@ -1,13 +0,0 @@
1
- # alias
2
-
3
- - **Type:** `Record<string, string> | Array<{ find: string | RegExp, replacement: string, customResolver?: ResolverFunction | ResolverObject }>`
4
-
5
- Define custom aliases when running inside tests. They will be merged with aliases from `resolve.alias`.
6
-
7
- ::: warning
8
- Vitest uses Vite SSR primitives to run tests which has [certain pitfalls](https://vitejs.dev/guide/ssr.html#ssr-externals).
9
-
10
- 1. Aliases affect only modules imported directly with an `import` keyword by an [inlined](/config/server#server-deps-inline) module (all source code is inlined by default).
11
- 2. Vitest does not support aliasing `require` calls.
12
- 3. If you are aliasing an external dependency (e.g., `react` -> `preact`), you may want to alias the actual `node_modules` packages instead to make it work for externalized dependencies. Both [Yarn](https://classic.yarnpkg.com/en/docs/cli/add/#toc-yarn-add-alias) and [pnpm](https://pnpm.io/aliases/) support aliasing via the `npm:` prefix.
13
- :::
@@ -1,32 +0,0 @@
1
- # allowOnly
2
-
3
- - **Type:** `boolean`
4
- - **Default:** `!process.env.CI`
5
- - **CLI:** `--allowOnly`, `--allowOnly=false`
6
-
7
- By default, Vitest does not permit tests marked with the [`only`](/api/test#test-only) flag in Continuous Integration (CI) environments. Conversely, in local development environments, Vitest allows these tests to run.
8
-
9
- ::: info
10
- Vitest uses [`std-env`](https://www.npmjs.com/package/std-env) package to detect the environment.
11
- :::
12
-
13
- You can customize this behavior by explicitly setting the `allowOnly` option to either `true` or `false`.
14
-
15
- ::: code-group
16
- ```js [vitest.config.js]
17
- import { defineConfig } from 'vitest/config'
18
-
19
- export default defineConfig({
20
- test: {
21
- allowOnly: true,
22
- },
23
- })
24
- ```
25
- ```bash [CLI]
26
- vitest --allowOnly
27
- ```
28
- :::
29
-
30
- When enabled, Vitest will not fail the test suite if tests marked with [`only`](/api/test#test-only) are detected, including in CI environments.
31
-
32
- When disabled, Vitest will fail the test suite if tests marked with [`only`](/api/test#test-only) are detected, including in local development environments.
@@ -1,27 +0,0 @@
1
- # api
2
-
3
- - **Type:** `boolean | number | object`
4
- - **Default:** `false`
5
- - **CLI:** `--api`, `--api.port`, `--api.host`, `--api.strictPort`
6
-
7
- Listen to port and serve API for [the UI](/guide/ui) or [browser server](/guide/browser/). When set to `true`, the default port is `51204`.
8
-
9
- ## api.allowWrite <Version>4.1.0</Version> {#api-allowwrite}
10
-
11
- - **Type:** `boolean`
12
- - **Default:** `true` if not exposed to the network, `false` otherwise
13
-
14
- Vitest server can save test files or snapshot files via the API. This allows anyone who can connect to the API the ability to run any arbitrary code on your machine.
15
-
16
- ::: danger SECURITY ADVICE
17
- Vitest does not expose the API to the internet by default and only listens on `localhost`. However if `host` is manually exposed to the network, anyone who connects to it can run arbitrary code on your machine, unless `api.allowWrite` and `api.allowExec` are set to `false`.
18
-
19
- If the host is set to anything other than `localhost` or `127.0.0.1`, Vitest will set `api.allowWrite` and `api.allowExec` to `false` by default. This means that any write operations (like changing the code in the UI) will not work. However, if you understand the security implications, you can override them.
20
- :::
21
-
22
- ## api.allowExec <Version>4.1.0</Version> {#api-allowexec}
23
-
24
- - **Type:** `boolean`
25
- - **Default:** `true` if not exposed to the network, `false` otherwise
26
-
27
- Allows running any test file via the API. See the security advice in [`api.allowWrite`](#api-allowwrite).
@@ -1,6 +0,0 @@
1
- # attachmentsDir
2
-
3
- - **Type:** `string`
4
- - **Default:** `'.vitest-attachments'`
5
-
6
- Directory path for storing attachments created by [`context.annotate`](/guide/test-context#annotate) relative to the project root.
@@ -1,9 +0,0 @@
1
- # bail
2
-
3
- - **Type:** `number`
4
- - **Default:** `0`
5
- - **CLI:** `--bail=<value>`
6
-
7
- Stop test execution when given number of tests have failed.
8
-
9
- By default Vitest will run all of your test cases even if some of them fail. This may not be desired for CI builds where you are only interested in 100% successful builds and would like to stop test execution as early as possible when test failures occur. The `bail` option can be used to speed up CI runs by preventing it from running more tests when failures have occurred.
@@ -1,65 +0,0 @@
1
- # benchmark <Experimental /> {#benchmark}
2
-
3
- - **Type:** `{ include?, exclude?, ... }`
4
-
5
- Options used when running `vitest bench`.
6
-
7
- ## benchmark.include
8
-
9
- - **Type:** `string[]`
10
- - **Default:** `['**/*.{bench,benchmark}.?(c|m)[jt]s?(x)']`
11
-
12
- Include globs for benchmark test files
13
-
14
- ## benchmark.exclude
15
-
16
- - **Type:** `string[]`
17
- - **Default:** `['node_modules', 'dist', '.idea', '.git', '.cache']`
18
-
19
- Exclude globs for benchmark test files
20
-
21
- ## benchmark.includeSource
22
-
23
- - **Type:** `string[]`
24
- - **Default:** `[]`
25
-
26
- Include globs for in-source benchmark test files. This option is similar to [`includeSource`](/config/include-source).
27
-
28
- When defined, Vitest will run all matched files with `import.meta.vitest` inside.
29
-
30
- ## benchmark.reporters
31
-
32
- - **Type:** `Arrayable<BenchmarkBuiltinReporters | Reporter>`
33
- - **Default:** `'default'`
34
-
35
- Custom reporter for output. Can contain one or more built-in report names, reporter instances, and/or paths to custom reporters.
36
-
37
- ## benchmark.outputFile
38
-
39
- Deprecated in favor of `benchmark.outputJson`.
40
-
41
- ## benchmark.outputJson {#benchmark-outputJson}
42
-
43
- - **Type:** `string | undefined`
44
- - **Default:** `undefined`
45
-
46
- A file path to store the benchmark result, which can be used for `--compare` option later.
47
-
48
- For example:
49
-
50
- ```sh
51
- # save main branch's result
52
- git checkout main
53
- vitest bench --outputJson main.json
54
-
55
- # change a branch and compare against main
56
- git checkout feature
57
- vitest bench --compare main.json
58
- ```
59
-
60
- ## benchmark.compare {#benchmark-compare}
61
-
62
- - **Type:** `string | undefined`
63
- - **Default:** `undefined`
64
-
65
- A file path to a previous benchmark result to compare against current runs.
@@ -1,23 +0,0 @@
1
- # browser.api
2
-
3
- - **Type:** `number | object`
4
- - **Default:** `63315`
5
- - **CLI:** `--browser.api=63315`, `--browser.api.port=1234, --browser.api.host=example.com`
6
-
7
- Configure options for Vite server that serves code in the browser. Does not affect [`test.api`](/config/api) option. By default, Vitest assigns port `63315` to avoid conflicts with the development server, allowing you to run both in parallel.
8
-
9
- ## api.allowWrite <Version>4.1.0</Version> {#api-allowwrite}
10
-
11
- - **Type:** `boolean`
12
- - **Default:** `true` if not exposed to the network, `false` otherwise
13
-
14
- Vitest saves [annotation attachments](/guide/test-annotations), [artifacts](/api/advanced/artifacts) and [snapshots](/guide/snapshot) by receiving a WebSocket connection from the browser. This allows anyone who can connect to the API write any arbitrary code on your machine within the root of your project (configured by [`fs.allow`](https://vite.dev/config/server-options#server-fs-allow)).
15
-
16
- If browser server is not exposed to the internet (the host is `localhost`), this should not be a problem, so the default value in that case is `true`. If you override the host, Vitest will set `allowWrite` to `false` by default to prevent potentially harmful writes.
17
-
18
- ## api.allowExec <Version>4.1.0</Version> {#api-allowexec}
19
-
20
- - **Type:** `boolean`
21
- - **Default:** `true` if not exposed to the network, `false` otherwise
22
-
23
- Allows running any test file via the UI. This only applies to the interactive elements (and the server code behind them) in the [UI](/guide/ui) that can run the code. If UI is disabled, this has no effect. See [`api.allowExec`](/config/api#api-allowexec) for more information.
@@ -1,6 +0,0 @@
1
- # browser.commands
2
-
3
- - **Type:** `Record<string, BrowserCommand>`
4
- - **Default:** `{ readFile, writeFile, ... }`
5
-
6
- Custom [commands](/api/browser/commands) that can be imported during browser tests from `vitest/browser`.
@@ -1,10 +0,0 @@
1
- # browser.connectTimeout
2
-
3
- - **Type:** `number`
4
- - **Default:** `60_000`
5
-
6
- The timeout in milliseconds. If connection to the browser takes longer, the test suite will fail.
7
-
8
- ::: info
9
- This is the time it should take for the browser to establish the WebSocket connection with the Vitest server. In normal circumstances, this timeout should never be reached.
10
- :::
@@ -1,38 +0,0 @@
1
- # browser.detailsPanelPosition
2
-
3
- - **Type:** `'right' | 'bottom'`
4
- - **Default:** `'right'`
5
- - **CLI:** `--browser.detailsPanelPosition=bottom`, `--browser.detailsPanelPosition=right`
6
-
7
- Controls the default position of the details panel in the Vitest UI when running browser tests.
8
-
9
- - `'right'` - Shows the details panel on the right side with a horizontal split between the browser viewport and the details panel.
10
- - `'bottom'` - Shows the details panel at the bottom with a vertical split between the browser viewport and the details panel.
11
-
12
- ```ts [vitest.config.ts]
13
- import { defineConfig } from 'vitest/config'
14
-
15
- export default defineConfig({
16
- test: {
17
- browser: {
18
- enabled: true,
19
- detailsPanelPosition: 'bottom', // or 'right'
20
- },
21
- },
22
- })
23
- ```
24
-
25
- ## Example
26
-
27
- ::: tabs
28
- == bottom
29
- <center>
30
- <img alt="Vitest UI with details at the bottom" img-light src="/ui/light-ui-details-bottom.png">
31
- <img alt="Vitest UI with details at the bottom" img-dark src="/ui/dark-ui-details-bottom.png">
32
- </center>
33
- == right
34
- <center>
35
- <img alt="Vitest UI with details at the right side" img-light src="/ui/light-ui-details-right.png">
36
- <img alt="Vitest UI with details at the right side" img-dark src="/ui/dark-ui-details-right.png">
37
- </center>
38
- :::
@@ -1,40 +0,0 @@
1
- # browser.enabled
2
-
3
- - **Type:** `boolean`
4
- - **Default:** `false`
5
- - **CLI:** `--browser`, `--browser.enabled=false`
6
-
7
- Enabling this flag makes Vitest run all tests in a [browser](/guide/browser/) by default. If you are configuring other browser options via the CLI, you can use `--browser.enabled` alongside them instead of `--browser`:
8
-
9
- ```sh
10
- vitest --browser.enabled --browser.headless
11
- ```
12
-
13
- ::: warning
14
- To enable [Browser Mode](/guide/browser/), you must also specify the [`provider`](/config/browser/provider) and at least one [`instance`](/config/browser/instances). Available providers:
15
-
16
- - [playwright](/config/browser/playwright)
17
- - [webdriverio](/config/browser/webdriverio)
18
- - [preview](/config/browser/preview)
19
- :::
20
-
21
- ## Example
22
-
23
- ```js{7} [vitest.config.js]
24
- import { defineConfig } from 'vitest/config'
25
- import { playwright } from '@vitest/browser-playwright'
26
-
27
- export default defineConfig({
28
- test: {
29
- browser: {
30
- enabled: true,
31
- provider: playwright(),
32
- instances: [
33
- { browser: 'chromium' },
34
- ],
35
- },
36
- },
37
- })
38
- ```
39
-
40
- If you use TypeScript, the `browser` field in `instances` provides autocompletion based on your provider.
@@ -1,250 +0,0 @@
1
- # browser.expect
2
-
3
- - **Type:** `ExpectOptions`
4
-
5
- ## browser.expect.toMatchScreenshot
6
-
7
- Default options for the
8
- [`toMatchScreenshot` assertion](/api/browser/assertions.html#tomatchscreenshot).
9
- These options will be applied to all screenshot assertions.
10
-
11
- ::: tip
12
- Setting global defaults for screenshot assertions helps maintain consistency
13
- across your test suite and reduces repetition in individual tests. You can still
14
- override these defaults at the assertion level when needed for specific test cases.
15
- :::
16
-
17
- ```ts
18
- import { defineConfig } from 'vitest/config'
19
-
20
- export default defineConfig({
21
- test: {
22
- browser: {
23
- enabled: true,
24
- expect: {
25
- toMatchScreenshot: {
26
- comparatorName: 'pixelmatch',
27
- comparatorOptions: {
28
- threshold: 0.2,
29
- allowedMismatchedPixels: 100,
30
- },
31
- resolveScreenshotPath: ({ arg, browserName, ext, testFileName }) =>
32
- `custom-screenshots/${testFileName}/${arg}-${browserName}${ext}`,
33
- },
34
- },
35
- },
36
- },
37
- })
38
- ```
39
-
40
- [All options available in the `toMatchScreenshot` assertion](/api/browser/assertions#options)
41
- can be configured here. Additionally, two path resolution functions are
42
- available: `resolveScreenshotPath` and `resolveDiffPath`.
43
-
44
- ## browser.expect.toMatchScreenshot.resolveScreenshotPath
45
-
46
- - **Type:** `(data: PathResolveData) => string`
47
- - **Default output:** `` `${root}/${testFileDirectory}/${screenshotDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}` ``
48
-
49
- A function to customize where reference screenshots are stored. The function
50
- receives an object with the following properties:
51
-
52
- - `arg: string`
53
-
54
- Path **without** extension, sanitized and relative to the test file.
55
-
56
- This comes from the arguments passed to `toMatchScreenshot`; if called
57
- without arguments this will be the auto-generated name.
58
-
59
- ```ts
60
- test('calls `onClick`', () => {
61
- expect(locator).toMatchScreenshot()
62
- // arg = "calls-onclick-1"
63
- })
64
-
65
- expect(locator).toMatchScreenshot('foo/bar/baz.png')
66
- // arg = "foo/bar/baz"
67
-
68
- expect(locator).toMatchScreenshot('../foo/bar/baz.png')
69
- // arg = "foo/bar/baz"
70
- ```
71
-
72
- - `ext: string`
73
-
74
- Screenshot extension, with leading dot.
75
-
76
- This can be set through the arguments passed to `toMatchScreenshot`, but
77
- the value will fall back to `'.png'` if an unsupported extension is used.
78
-
79
- - `browserName: string`
80
-
81
- The instance's browser name.
82
-
83
- - `platform: NodeJS.Platform`
84
-
85
- The value of
86
- [`process.platform`](https://nodejs.org/docs/v22.16.0/api/process.html#processplatform).
87
-
88
- - `screenshotDirectory: string`
89
-
90
- The value provided to
91
- [`browser.screenshotDirectory`](/config/browser/screenshotdirectory),
92
- if none is provided, its default value.
93
-
94
- - `root: string`
95
-
96
- Absolute path to the project's [`root`](/config/root).
97
-
98
- - `testFileDirectory: string`
99
-
100
- Path to the test file, relative to the project's [`root`](/config/root).
101
-
102
- - `testFileName: string`
103
-
104
- The test's filename.
105
-
106
- - `testName: string`
107
-
108
- The [`test`](/api/test)'s name, including parent
109
- [`describe`](/api/describe), sanitized.
110
-
111
- - `attachmentsDir: string`
112
-
113
- The value provided to [`attachmentsDir`](/config/attachmentsdir), if none is
114
- provided, its default value.
115
-
116
- For example, to group screenshots by browser:
117
-
118
- ```ts
119
- resolveScreenshotPath: ({ arg, browserName, ext, root, testFileName }) =>
120
- `${root}/screenshots/${browserName}/${testFileName}/${arg}${ext}`
121
- ```
122
-
123
- ## browser.expect.toMatchScreenshot.resolveDiffPath
124
-
125
- - **Type:** `(data: PathResolveData) => string`
126
- - **Default output:** `` `${root}/${attachmentsDir}/${testFileDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}` ``
127
-
128
- A function to customize where diff images are stored when screenshot comparisons
129
- fail. Receives the same data object as
130
- [`resolveScreenshotPath`](#browser-expect-tomatchscreenshot-resolvescreenshotpath).
131
-
132
- For example, to store diffs in a subdirectory of attachments:
133
-
134
- ```ts
135
- resolveDiffPath: ({ arg, attachmentsDir, browserName, ext, root, testFileName }) =>
136
- `${root}/${attachmentsDir}/screenshot-diffs/${testFileName}/${arg}-${browserName}${ext}`
137
- ```
138
-
139
- ## browser.expect.toMatchScreenshot.comparators
140
-
141
- - **Type:** `Record<string, Comparator>`
142
-
143
- Register custom screenshot comparison algorithms, like [SSIM](https://en.wikipedia.org/wiki/Structural_similarity_index_measure) or other perceptual similarity metrics.
144
-
145
- To create a custom comparator, you need to register it in your config. If using TypeScript, declare its options in the `ScreenshotComparatorRegistry` interface.
146
-
147
- ```ts
148
- import { defineConfig } from 'vitest/config'
149
-
150
- // 1. Declare the comparator's options type
151
- declare module 'vitest/browser' {
152
- interface ScreenshotComparatorRegistry {
153
- myCustomComparator: {
154
- sensitivity?: number
155
- ignoreColors?: boolean
156
- }
157
- }
158
- }
159
-
160
- // 2. Implement the comparator
161
- export default defineConfig({
162
- test: {
163
- browser: {
164
- expect: {
165
- toMatchScreenshot: {
166
- comparators: {
167
- myCustomComparator: async (
168
- reference,
169
- actual,
170
- {
171
- createDiff, // always provided by Vitest
172
- sensitivity = 0.01,
173
- ignoreColors = false,
174
- }
175
- ) => {
176
- // ...algorithm implementation
177
- return { pass, diff, message }
178
- },
179
- },
180
- },
181
- },
182
- },
183
- },
184
- })
185
- ```
186
-
187
- Then use it in your tests:
188
-
189
- ```ts
190
- await expect(locator).toMatchScreenshot({
191
- comparatorName: 'myCustomComparator',
192
- comparatorOptions: {
193
- sensitivity: 0.08,
194
- ignoreColors: true,
195
- },
196
- })
197
- ```
198
-
199
- **Comparator Function Signature:**
200
-
201
- ```ts
202
- type Comparator<Options> = (
203
- reference: {
204
- metadata: { height: number; width: number }
205
- data: TypedArray
206
- },
207
- actual: {
208
- metadata: { height: number; width: number }
209
- data: TypedArray
210
- },
211
- options: {
212
- createDiff: boolean
213
- } & Options
214
- ) => Promise<{
215
- pass: boolean
216
- diff: TypedArray | null
217
- message: string | null
218
- }> | {
219
- pass: boolean
220
- diff: TypedArray | null
221
- message: string | null
222
- }
223
- ```
224
-
225
- The `reference` and `actual` images are decoded using the appropriate codec (currently only PNG). The `data` property is a flat `TypedArray` (`Buffer`, `Uint8Array`, or `Uint8ClampedArray`) containing pixel data in RGBA format:
226
-
227
- - **4 bytes per pixel**: red, green, blue, alpha (from `0` to `255` each)
228
- - **Row-major order**: pixels are stored left-to-right, top-to-bottom
229
- - **Total length**: `width × height × 4` bytes
230
- - **Alpha channel**: always present. Images without transparency have alpha values set to `255` (fully opaque)
231
-
232
- ::: tip Performance Considerations
233
- The `createDiff` option indicates whether a diff image is needed. During [stable screenshot detection](/guide/browser/visual-regression-testing#how-visual-tests-work), Vitest calls comparators with `createDiff: false` to avoid unnecessary work.
234
-
235
- **Respect this flag to keep your tests fast**.
236
- :::
237
-
238
- ::: warning Handle Missing Options
239
- The `options` parameter in `toMatchScreenshot()` is optional, so users might not provide all your comparator options. Always make them optional with default values:
240
-
241
- ```ts
242
- myCustomComparator: (
243
- reference,
244
- actual,
245
- { createDiff, threshold = 0.1, maxDiff = 100 },
246
- ) => {
247
- // ...comparison logic
248
- }
249
- ```
250
- :::
@@ -1,7 +0,0 @@
1
- # browser.headless
2
-
3
- - **Type:** `boolean`
4
- - **Default:** `process.env.CI`
5
- - **CLI:** `--browser.headless`, `--browser.headless=false`
6
-
7
- Run the browser in a `headless` mode. If you are running Vitest in CI, it will be enabled by default.
@@ -1,47 +0,0 @@
1
- # browser.instances
2
-
3
- - **Type:** `BrowserConfig`
4
- - **Default:** `[]`
5
-
6
- Defines multiple browser setups. Every config has to have at least a `browser` field.
7
-
8
- You can specify most of the [project options](/config/) (not marked with a <CRoot /> icon) and some of the `browser` options like `browser.testerHtmlPath`.
9
-
10
- ::: warning
11
- Every browser config inherits options from the root config:
12
-
13
- ```ts{3,9} [vitest.config.ts]
14
- export default defineConfig({
15
- test: {
16
- setupFile: ['./root-setup-file.js'],
17
- browser: {
18
- enabled: true,
19
- testerHtmlPath: './custom-path.html',
20
- instances: [
21
- {
22
- // will have both setup files: "root" and "browser"
23
- setupFile: ['./browser-setup-file.js'],
24
- // implicitly has "testerHtmlPath" from the root config // [!code warning]
25
- // testerHtmlPath: './custom-path.html', // [!code warning]
26
- },
27
- ],
28
- },
29
- },
30
- })
31
- ```
32
-
33
- For more examples, refer to the ["Multiple Setups" guide](/guide/browser/multiple-setups).
34
- :::
35
-
36
- List of available `browser` options:
37
-
38
- - `browser` (the name of the browser)
39
- - [`headless`](/config/browser/headless)
40
- - [`locators`](/config/browser/locators)
41
- - [`viewport`](/config/browser/viewport)
42
- - [`testerHtmlPath`](/config/browser/testerhtmlpath)
43
- - [`screenshotDirectory`](/config/browser/screenshotdirectory)
44
- - [`screenshotFailures`](/config/browser/screenshotfailures)
45
- - [`provider`](/config/browser/provider)
46
-
47
- Under the hood, Vitest transforms these instances into separate [test projects](/api/advanced/test-project) sharing a single Vite server for better caching performance.
@@ -1,11 +0,0 @@
1
- # browser.isolate <Deprecated />
2
-
3
- - **Type:** `boolean`
4
- - **Default:** the same as [`--isolate`](/config/isolate)
5
- - **CLI:** `--browser.isolate`, `--browser.isolate=false`
6
-
7
- Run every test in a separate iframe.
8
-
9
- ::: danger DEPRECATED
10
- This option is deprecated. Use [`isolate`](/config/isolate) instead.
11
- :::
@@ -1,24 +0,0 @@
1
- # browser.locators
2
-
3
- Options for built-in [browser locators](/api/browser/locators).
4
-
5
- ## browser.locators.testIdAttribute
6
-
7
- - **Type:** `string`
8
- - **Default:** `data-testid`
9
-
10
- Attribute used to find elements with `getByTestId` locator.
11
-
12
- ## browser.locators.exact <Version type="experimental">4.1.3</Version> {#browser-locators-exact}
13
-
14
- - **Type:** `boolean`
15
- - **Default:** `false`
16
-
17
- When set to `true`, [locators](/api/browser/locators) will match text exactly by default, requiring a full, case-sensitive match. Individual locator calls can override this default via their own `exact` option.
18
-
19
- ```ts
20
- // With exact: false (default), this matches "Hello, World!", "Say Hello, World", etc.
21
- // With exact: true, this only matches the string "Hello, World" exactly.
22
- const locator = page.getByText('Hello, World', { exact: true })
23
- await locator.click()
24
- ```
@@ -1,39 +0,0 @@
1
- # browser.orchestratorScripts
2
-
3
- - **Type:** `BrowserScript[]`
4
- - **Default:** `[]`
5
-
6
- Custom scripts that should be injected into the orchestrator HTML before test iframes are initiated. This HTML document only sets up iframes and doesn't actually import your code.
7
-
8
- The script `src` and `content` will be processed by Vite plugins. Script should be provided in the following shape:
9
-
10
- ```ts
11
- export interface BrowserScript {
12
- /**
13
- * If "content" is provided and type is "module", this will be its identifier.
14
- *
15
- * If you are using TypeScript, you can add `.ts` extension here for example.
16
- * @default `injected-${index}.js`
17
- */
18
- id?: string
19
- /**
20
- * JavaScript content to be injected. This string is processed by Vite plugins if type is "module".
21
- *
22
- * You can use `id` to give Vite a hint about the file extension.
23
- */
24
- content?: string
25
- /**
26
- * Path to the script. This value is resolved by Vite so it can be a node module or a file path.
27
- */
28
- src?: string
29
- /**
30
- * If the script should be loaded asynchronously.
31
- */
32
- async?: boolean
33
- /**
34
- * Script type.
35
- * @default 'module'
36
- */
37
- type?: string
38
- }
39
- ```