@vitest-agent/mcp 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/README.md +1 -2
  2. package/index.d.ts +2 -2
  3. package/index.js +1 -1
  4. package/package.json +1 -1
  5. package/server.js +2 -4
  6. package/patterns/_meta.json +0 -67
  7. package/patterns/authoring-a-custom-vitest-agent-reporter.md +0 -82
  8. package/patterns/known-issues-and-caveats.md +0 -52
  9. package/patterns/operating-vitest-agent-as-an-agent.md +0 -62
  10. package/patterns/running-tests-via-mcp.md +0 -103
  11. package/patterns/silencing-leaking-output-in-tests.md +0 -91
  12. package/patterns/testing-effect-schema-definitions.md +0 -71
  13. package/patterns/testing-effect-services-with-mock-layers.md +0 -63
  14. package/resources/index.js +0 -166
  15. package/resources/indexes.js +0 -77
  16. package/resources/manifest-schema.js +0 -46
  17. package/resources/paths.js +0 -20
  18. package/resources/patterns.js +0 -22
  19. package/resources/upstream-docs.js +0 -22
  20. package/vendor/vitest-docs/ATTRIBUTION.md +0 -5
  21. package/vendor/vitest-docs/api/advanced/artifacts.md +0 -189
  22. package/vendor/vitest-docs/api/advanced/metadata.md +0 -68
  23. package/vendor/vitest-docs/api/advanced/plugin.md +0 -168
  24. package/vendor/vitest-docs/api/advanced/reporters.md +0 -342
  25. package/vendor/vitest-docs/api/advanced/runner.md +0 -334
  26. package/vendor/vitest-docs/api/advanced/test-case.md +0 -302
  27. package/vendor/vitest-docs/api/advanced/test-collection.md +0 -89
  28. package/vendor/vitest-docs/api/advanced/test-module.md +0 -140
  29. package/vendor/vitest-docs/api/advanced/test-project.md +0 -321
  30. package/vendor/vitest-docs/api/advanced/test-specification.md +0 -96
  31. package/vendor/vitest-docs/api/advanced/test-suite.md +0 -230
  32. package/vendor/vitest-docs/api/advanced/vitest.md +0 -684
  33. package/vendor/vitest-docs/api/assert-type.md +0 -22
  34. package/vendor/vitest-docs/api/assert.md +0 -1960
  35. package/vendor/vitest-docs/api/browser/assertions.md +0 -1277
  36. package/vendor/vitest-docs/api/browser/commands.md +0 -154
  37. package/vendor/vitest-docs/api/browser/context.md +0 -338
  38. package/vendor/vitest-docs/api/browser/interactivity.md +0 -681
  39. package/vendor/vitest-docs/api/browser/locators.md +0 -1171
  40. package/vendor/vitest-docs/api/browser/react.md +0 -346
  41. package/vendor/vitest-docs/api/browser/svelte.md +0 -292
  42. package/vendor/vitest-docs/api/browser/vue.md +0 -222
  43. package/vendor/vitest-docs/api/describe.md +0 -374
  44. package/vendor/vitest-docs/api/expect-typeof.md +0 -571
  45. package/vendor/vitest-docs/api/expect.md +0 -2304
  46. package/vendor/vitest-docs/api/hooks.md +0 -463
  47. package/vendor/vitest-docs/api/mock.md +0 -701
  48. package/vendor/vitest-docs/api/test.md +0 -926
  49. package/vendor/vitest-docs/api/vi.md +0 -1372
  50. package/vendor/vitest-docs/config/alias.md +0 -13
  51. package/vendor/vitest-docs/config/allowonly.md +0 -32
  52. package/vendor/vitest-docs/config/api.md +0 -27
  53. package/vendor/vitest-docs/config/attachmentsdir.md +0 -6
  54. package/vendor/vitest-docs/config/bail.md +0 -9
  55. package/vendor/vitest-docs/config/benchmark.md +0 -65
  56. package/vendor/vitest-docs/config/browser/api.md +0 -23
  57. package/vendor/vitest-docs/config/browser/commands.md +0 -6
  58. package/vendor/vitest-docs/config/browser/connecttimeout.md +0 -10
  59. package/vendor/vitest-docs/config/browser/detailspanelposition.md +0 -38
  60. package/vendor/vitest-docs/config/browser/enabled.md +0 -40
  61. package/vendor/vitest-docs/config/browser/expect.md +0 -250
  62. package/vendor/vitest-docs/config/browser/headless.md +0 -7
  63. package/vendor/vitest-docs/config/browser/instances.md +0 -47
  64. package/vendor/vitest-docs/config/browser/isolate.md +0 -11
  65. package/vendor/vitest-docs/config/browser/locators.md +0 -24
  66. package/vendor/vitest-docs/config/browser/orchestratorscripts.md +0 -39
  67. package/vendor/vitest-docs/config/browser/playwright.md +0 -214
  68. package/vendor/vitest-docs/config/browser/preview.md +0 -32
  69. package/vendor/vitest-docs/config/browser/provider.md +0 -79
  70. package/vendor/vitest-docs/config/browser/screenshotdirectory.md +0 -6
  71. package/vendor/vitest-docs/config/browser/screenshotfailures.md +0 -6
  72. package/vendor/vitest-docs/config/browser/testerhtmlpath.md +0 -5
  73. package/vendor/vitest-docs/config/browser/trace.md +0 -43
  74. package/vendor/vitest-docs/config/browser/trackunhandlederrors.md +0 -10
  75. package/vendor/vitest-docs/config/browser/ui.md +0 -7
  76. package/vendor/vitest-docs/config/browser/viewport.md +0 -6
  77. package/vendor/vitest-docs/config/browser/webdriverio.md +0 -64
  78. package/vendor/vitest-docs/config/cache.md +0 -26
  79. package/vendor/vitest-docs/config/chaiconfig.md +0 -29
  80. package/vendor/vitest-docs/config/clearmocks.md +0 -22
  81. package/vendor/vitest-docs/config/coverage.md +0 -455
  82. package/vendor/vitest-docs/config/css.md +0 -47
  83. package/vendor/vitest-docs/config/dangerouslyignoreunhandlederrors.md +0 -23
  84. package/vendor/vitest-docs/config/deps.md +0 -127
  85. package/vendor/vitest-docs/config/detectasyncleaks.md +0 -39
  86. package/vendor/vitest-docs/config/diff.md +0 -96
  87. package/vendor/vitest-docs/config/dir.md +0 -7
  88. package/vendor/vitest-docs/config/disableconsoleintercept.md +0 -15
  89. package/vendor/vitest-docs/config/env.md +0 -5
  90. package/vendor/vitest-docs/config/environment.md +0 -96
  91. package/vendor/vitest-docs/config/environmentoptions.md +0 -30
  92. package/vendor/vitest-docs/config/exclude.md +0 -49
  93. package/vendor/vitest-docs/config/execargv.md +0 -10
  94. package/vendor/vitest-docs/config/expandsnapshotdiff.md +0 -7
  95. package/vendor/vitest-docs/config/expect.md +0 -38
  96. package/vendor/vitest-docs/config/experimental.md +0 -510
  97. package/vendor/vitest-docs/config/faketimers.md +0 -51
  98. package/vendor/vitest-docs/config/fileparallelism.md +0 -11
  99. package/vendor/vitest-docs/config/forcereruntriggers.md +0 -19
  100. package/vendor/vitest-docs/config/globals.md +0 -42
  101. package/vendor/vitest-docs/config/globalsetup.md +0 -72
  102. package/vendor/vitest-docs/config/hideskippedtests.md +0 -7
  103. package/vendor/vitest-docs/config/hooktimeout.md +0 -7
  104. package/vendor/vitest-docs/config/include-source.md +0 -115
  105. package/vendor/vitest-docs/config/include.md +0 -71
  106. package/vendor/vitest-docs/config/includetasklocation.md +0 -17
  107. package/vendor/vitest-docs/config/index.md +0 -85
  108. package/vendor/vitest-docs/config/isolate.md +0 -13
  109. package/vendor/vitest-docs/config/logheapusage.md +0 -7
  110. package/vendor/vitest-docs/config/maxconcurrency.md +0 -9
  111. package/vendor/vitest-docs/config/maxworkers.md +0 -49
  112. package/vendor/vitest-docs/config/mockreset.md +0 -22
  113. package/vendor/vitest-docs/config/mode.md +0 -7
  114. package/vendor/vitest-docs/config/name.md +0 -111
  115. package/vendor/vitest-docs/config/onconsolelog.md +0 -25
  116. package/vendor/vitest-docs/config/onstacktrace.md +0 -32
  117. package/vendor/vitest-docs/config/onunhandlederror.md +0 -35
  118. package/vendor/vitest-docs/config/open.md +0 -7
  119. package/vendor/vitest-docs/config/outputfile.md +0 -7
  120. package/vendor/vitest-docs/config/passwithnotests.md +0 -7
  121. package/vendor/vitest-docs/config/pool.md +0 -45
  122. package/vendor/vitest-docs/config/printconsoletrace.md +0 -6
  123. package/vendor/vitest-docs/config/projects.md +0 -6
  124. package/vendor/vitest-docs/config/provide.md +0 -45
  125. package/vendor/vitest-docs/config/reporters.md +0 -69
  126. package/vendor/vitest-docs/config/resolvesnapshotpath.md +0 -36
  127. package/vendor/vitest-docs/config/restoremocks.md +0 -22
  128. package/vendor/vitest-docs/config/retry.md +0 -140
  129. package/vendor/vitest-docs/config/root.md +0 -6
  130. package/vendor/vitest-docs/config/runner.md +0 -6
  131. package/vendor/vitest-docs/config/sequence.md +0 -158
  132. package/vendor/vitest-docs/config/server.md +0 -68
  133. package/vendor/vitest-docs/config/setupfiles.md +0 -40
  134. package/vendor/vitest-docs/config/silent.md +0 -9
  135. package/vendor/vitest-docs/config/slowtestthreshold.md +0 -7
  136. package/vendor/vitest-docs/config/snapshotenvironment.md +0 -27
  137. package/vendor/vitest-docs/config/snapshotformat.md +0 -28
  138. package/vendor/vitest-docs/config/snapshotserializers.md +0 -6
  139. package/vendor/vitest-docs/config/stricttags.md +0 -30
  140. package/vendor/vitest-docs/config/tags.md +0 -141
  141. package/vendor/vitest-docs/config/teardowntimeout.md +0 -7
  142. package/vendor/vitest-docs/config/testnamepattern.md +0 -21
  143. package/vendor/vitest-docs/config/testtimeout.md +0 -7
  144. package/vendor/vitest-docs/config/typecheck.md +0 -77
  145. package/vendor/vitest-docs/config/ui.md +0 -15
  146. package/vendor/vitest-docs/config/unstubenvs.md +0 -20
  147. package/vendor/vitest-docs/config/unstubglobals.md +0 -20
  148. package/vendor/vitest-docs/config/update.md +0 -16
  149. package/vendor/vitest-docs/config/vmmemorylimit.md +0 -30
  150. package/vendor/vitest-docs/config/watch.md +0 -11
  151. package/vendor/vitest-docs/config/watchtriggerpatterns.md +0 -29
  152. package/vendor/vitest-docs/guide/advanced/index.md +0 -147
  153. package/vendor/vitest-docs/guide/advanced/pool.md +0 -148
  154. package/vendor/vitest-docs/guide/advanced/reporters.md +0 -93
  155. package/vendor/vitest-docs/guide/advanced/tests.md +0 -125
  156. package/vendor/vitest-docs/guide/browser/aria-snapshots.md +0 -470
  157. package/vendor/vitest-docs/guide/browser/component-testing.md +0 -571
  158. package/vendor/vitest-docs/guide/browser/index.md +0 -630
  159. package/vendor/vitest-docs/guide/browser/multiple-setups.md +0 -121
  160. package/vendor/vitest-docs/guide/browser/trace-view.md +0 -126
  161. package/vendor/vitest-docs/guide/browser/visual-regression-testing.md +0 -734
  162. package/vendor/vitest-docs/guide/cli-generated.md +0 -972
  163. package/vendor/vitest-docs/guide/cli.md +0 -234
  164. package/vendor/vitest-docs/guide/common-errors.md +0 -163
  165. package/vendor/vitest-docs/guide/coverage.md +0 -515
  166. package/vendor/vitest-docs/guide/debugging.md +0 -127
  167. package/vendor/vitest-docs/guide/environment.md +0 -101
  168. package/vendor/vitest-docs/guide/extending-matchers.md +0 -160
  169. package/vendor/vitest-docs/guide/features.md +0 -310
  170. package/vendor/vitest-docs/guide/filtering.md +0 -175
  171. package/vendor/vitest-docs/guide/ide.md +0 -43
  172. package/vendor/vitest-docs/guide/improving-performance.md +0 -245
  173. package/vendor/vitest-docs/guide/in-source.md +0 -159
  174. package/vendor/vitest-docs/guide/index.md +0 -128
  175. package/vendor/vitest-docs/guide/learn/async.md +0 -147
  176. package/vendor/vitest-docs/guide/learn/debugging-tests.md +0 -210
  177. package/vendor/vitest-docs/guide/learn/matchers.md +0 -277
  178. package/vendor/vitest-docs/guide/learn/mock-functions.md +0 -277
  179. package/vendor/vitest-docs/guide/learn/setup-teardown.md +0 -240
  180. package/vendor/vitest-docs/guide/learn/snapshots.md +0 -166
  181. package/vendor/vitest-docs/guide/learn/testing-in-practice.md +0 -430
  182. package/vendor/vitest-docs/guide/learn/writing-tests-with-ai.md +0 -127
  183. package/vendor/vitest-docs/guide/learn/writing-tests.md +0 -231
  184. package/vendor/vitest-docs/guide/lifecycle.md +0 -379
  185. package/vendor/vitest-docs/guide/migration.md +0 -863
  186. package/vendor/vitest-docs/guide/mocking/classes.md +0 -158
  187. package/vendor/vitest-docs/guide/mocking/dates.md +0 -52
  188. package/vendor/vitest-docs/guide/mocking/file-system.md +0 -74
  189. package/vendor/vitest-docs/guide/mocking/functions.md +0 -61
  190. package/vendor/vitest-docs/guide/mocking/globals.md +0 -20
  191. package/vendor/vitest-docs/guide/mocking/modules.md +0 -414
  192. package/vendor/vitest-docs/guide/mocking/requests.md +0 -114
  193. package/vendor/vitest-docs/guide/mocking/timers.md +0 -48
  194. package/vendor/vitest-docs/guide/mocking.md +0 -239
  195. package/vendor/vitest-docs/guide/open-telemetry.md +0 -156
  196. package/vendor/vitest-docs/guide/parallelism.md +0 -82
  197. package/vendor/vitest-docs/guide/profiling-test-performance.md +0 -243
  198. package/vendor/vitest-docs/guide/projects.md +0 -291
  199. package/vendor/vitest-docs/guide/recipes.md +0 -59
  200. package/vendor/vitest-docs/guide/reporters.md +0 -723
  201. package/vendor/vitest-docs/guide/snapshot.md +0 -620
  202. package/vendor/vitest-docs/guide/test-annotations.md +0 -103
  203. package/vendor/vitest-docs/guide/test-context.md +0 -902
  204. package/vendor/vitest-docs/guide/test-tags.md +0 -314
  205. package/vendor/vitest-docs/guide/testing-types.md +0 -149
  206. package/vendor/vitest-docs/guide/ui.md +0 -160
  207. package/vendor/vitest-docs/guide/using-plugins.md +0 -5
  208. package/vendor/vitest-docs/manifest.json +0 -1691
@@ -1,72 +0,0 @@
1
- # globalSetup
2
-
3
- - **Type:** `string | string[]`
4
-
5
- Path to global setup files relative to project [root](/config/root).
6
-
7
- A global setup file can either export named functions `setup` and `teardown` or a `default` function that returns a teardown function:
8
-
9
- ::: code-group
10
- ```js [exports]
11
- export function setup(project) {
12
- console.log('setup')
13
- }
14
-
15
- export function teardown() {
16
- console.log('teardown')
17
- }
18
- ```
19
- ```js [default]
20
- export default function setup(project) {
21
- console.log('setup')
22
-
23
- return function teardown() {
24
- console.log('teardown')
25
- }
26
- }
27
- ```
28
- :::
29
-
30
- Note that the `setup` method and a `default` function receive a [test project](/api/advanced/test-project) as the first argument. The global setup is called before the test workers are created and only if there is at least one test queued, and teardown is called after all test files have finished running. In [watch mode](/config/watch), the teardown is called before the process is exited instead. If you need to reconfigure your setup before the test rerun, you can use [`onTestsRerun`](#handling-test-reruns) hook instead.
31
-
32
- Multiple global setup files are possible. `setup` and `teardown` are executed sequentially with teardown in reverse order.
33
-
34
- ::: danger
35
- Beware that the global setup is running in a different global scope before test workers are even created, so your tests don't have access to global variables defined here. However, you can pass down serializable data to tests via [`provide`](/config/provide) method and read them in your tests via `inject` imported from `vitest`:
36
-
37
- :::code-group
38
- ```ts [example.test.ts]
39
- import { inject } from 'vitest'
40
-
41
- inject('wsPort') === 3000
42
- ```
43
- ```ts [globalSetup.ts]
44
- import type { TestProject } from 'vitest/node'
45
-
46
- export default function setup(project: TestProject) {
47
- project.provide('wsPort', 3000)
48
- }
49
-
50
- declare module 'vitest' {
51
- export interface ProvidedContext {
52
- wsPort: number
53
- }
54
- }
55
- ```
56
-
57
- If you need to execute code in the same process as tests, use [`setupFiles`](/config/setupfiles) instead, but note that it runs before every test file.
58
- :::
59
-
60
- ## Handling Test Reruns
61
-
62
- You can define a custom callback function to be called when Vitest reruns tests. The test runner will wait for it to complete before executing tests. Note that you cannot destruct the `project` like `{ onTestsRerun }` because it relies on the context.
63
-
64
- ```ts [globalSetup.ts]
65
- import type { TestProject } from 'vitest/node'
66
-
67
- export default function setup(project: TestProject) {
68
- project.onTestsRerun(async () => {
69
- await restartDb()
70
- })
71
- }
72
- ```
@@ -1,7 +0,0 @@
1
- # hideSkippedTests
2
-
3
- - **Type:** `boolean`
4
- - **CLI:** `--hideSkippedTests`, `--hide-skipped-tests`
5
- - **Default:** `false`
6
-
7
- Hide logs for skipped tests
@@ -1,7 +0,0 @@
1
- # hookTimeout
2
-
3
- - **Type:** `number`
4
- - **Default:** `10_000` in Node.js, `30_000` if `browser.enabled` is `true`
5
- - **CLI:** `--hook-timeout=10000`, `--hookTimeout=10000`
6
-
7
- Default timeout of a hook in milliseconds. Use `0` to disable timeout completely.
@@ -1,115 +0,0 @@
1
- # includeSource
2
-
3
- - **Type:** `string[]`
4
- - **Default:** `[]`
5
-
6
- A list of [glob patterns](https://superchupu.dev/tinyglobby/comparison) that match your [in-source test files](/guide/in-source). These patterns are resolved relative to the [`root`](/config/root) ([`process.cwd()`](https://nodejs.org/api/process.html#processcwd) by default).
7
-
8
- When defined, Vitest will run all matched files that have `import.meta.vitest` inside.
9
-
10
- ::: warning
11
- Vitest performs a simple text-based inclusion check on source files. If a file contains `import.meta.vitest`, even in a comment, it will be matched as an in-source test file.
12
- :::
13
-
14
- Vitest uses the [`tinyglobby`](https://npmx.dev/package/tinyglobby) package to resolve the globs.
15
-
16
- ## Example
17
-
18
- ```js
19
- import { defineConfig } from 'vitest/config'
20
-
21
- export default defineConfig({
22
- test: {
23
- includeSource: ['src/**/*.{js,ts}'],
24
- },
25
- })
26
- ```
27
-
28
- Then you can write tests inside your source files:
29
-
30
- ```ts [src/index.ts]
31
- export function add(...args: number[]) {
32
- return args.reduce((a, b) => a + b, 0)
33
- }
34
-
35
- // #region in-source test suites
36
- if (import.meta.vitest) {
37
- const { it, expect } = import.meta.vitest
38
- it('add', () => {
39
- expect(add()).toBe(0)
40
- expect(add(1)).toBe(1)
41
- expect(add(1, 2, 3)).toBe(6)
42
- })
43
- }
44
- // #endregion
45
- ```
46
-
47
- For your production build, you need to replace the `import.meta.vitest` with `undefined`, letting the bundler do the dead code elimination.
48
-
49
- ::: code-group
50
- ```js [vite.config.ts]
51
- import { defineConfig } from 'vite'
52
-
53
- export default defineConfig({
54
- define: { // [!code ++]
55
- 'import.meta.vitest': 'undefined', // [!code ++]
56
- }, // [!code ++]
57
- })
58
- ```
59
- ```js [rolldown.config.js]
60
- import { defineConfig } from 'rolldown/config'
61
-
62
- export default defineConfig({
63
- transform: {
64
- define: { // [!code ++]
65
- 'import.meta.vitest': 'undefined', // [!code ++]
66
- }, // [!code ++]
67
- },
68
- })
69
- ```
70
- ```js [rollup.config.js]
71
- import replace from '@rollup/plugin-replace' // [!code ++]
72
-
73
- export default {
74
- plugins: [
75
- replace({ // [!code ++]
76
- 'import.meta.vitest': 'undefined', // [!code ++]
77
- }) // [!code ++]
78
- ],
79
- // other options
80
- }
81
- ```
82
- ```js [build.config.js]
83
- import { defineBuildConfig } from 'unbuild'
84
-
85
- export default defineBuildConfig({
86
- replace: { // [!code ++]
87
- 'import.meta.vitest': 'undefined', // [!code ++]
88
- }, // [!code ++]
89
- // other options
90
- })
91
- ```
92
- ```js [webpack.config.js]
93
- const webpack = require('webpack')
94
-
95
- module.exports = {
96
- plugins: [
97
- new webpack.DefinePlugin({ // [!code ++]
98
- 'import.meta.vitest': 'undefined', // [!code ++]
99
- })// [!code ++]
100
- ],
101
- }
102
- ```
103
- :::
104
-
105
- ::: tip
106
- To get TypeScript support for `import.meta.vitest`, add `vitest/importMeta` to your `tsconfig.json`:
107
-
108
- ```json [tsconfig.json]
109
- {
110
- "compilerOptions": {
111
- "types": ["vitest/importMeta"]
112
- }
113
- }
114
- ```
115
- :::
@@ -1,71 +0,0 @@
1
- # include
2
-
3
- - **Type:** `string[]`
4
- - **Default:** `['**/*.{test,spec}.?(c|m)[jt]s?(x)']`
5
- - **CLI:** `vitest [...include]`, `vitest **/*.test.js`
6
-
7
- A list of [glob patterns](https://superchupu.dev/tinyglobby/comparison) that match your test files. These patterns are resolved relative to the [`root`](/config/root) ([`process.cwd()`](https://nodejs.org/api/process.html#processcwd) by default).
8
-
9
- Vitest uses the [`tinyglobby`](https://npmx.dev/package/tinyglobby) package to resolve the globs.
10
-
11
- ::: tip NOTE
12
- When using coverage, Vitest automatically adds test files `include` patterns to coverage's default `exclude` patterns. See [`coverage.exclude`](/config/coverage#exclude).
13
- :::
14
-
15
- ## Example
16
-
17
- ```js
18
- import { defineConfig } from 'vitest/config'
19
-
20
- export default defineConfig({
21
- test: {
22
- include: [
23
- './test',
24
- './**/*.{test,spec}.tsx?',
25
- ],
26
- },
27
- })
28
- ```
29
-
30
- Vitest provides reasonable defaults, so normally you wouldn't override them. A good example of defining `include` is for [test projects](/guide/projects):
31
-
32
- ```js{8,12} [vitest.config.js]
33
- import { defineConfig } from 'vitest/config'
34
-
35
- export default defineConfig({
36
- test: {
37
- projects: [
38
- {
39
- test: {
40
- name: 'unit',
41
- include: ['./test/unit/*.test.js'],
42
- },
43
- },
44
- {
45
- test: {
46
- name: 'e2e',
47
- include: ['./test/e2e/*.test.js'],
48
- },
49
- },
50
- ],
51
- },
52
- })
53
- ```
54
-
55
- ::: warning
56
- This option will override Vitest defaults. If you just want to extend them, use `configDefaults` from `vitest/config`:
57
-
58
- ```js{6}
59
- import { configDefaults, defineConfig } from 'vitest/config'
60
-
61
- export default defineConfig({
62
- test: {
63
- include: [
64
- ...configDefaults.include,
65
- './test',
66
- './**/*.{test,spec}.tsx?',
67
- ],
68
- },
69
- })
70
- ```
71
- :::
@@ -1,17 +0,0 @@
1
- # includeTaskLocation
2
-
3
- - **Type:** `boolean`
4
- - **Default:** `false`
5
-
6
- Should `location` property be included when Vitest API receives tasks in [reporters](/config/reporters). If you have a lot of tests, this might cause a small performance regression.
7
-
8
- The `location` property has `column` and `line` values that correspond to the `test` or `describe` position in the original file.
9
-
10
- This option will be auto-enabled if you don't disable it explicitly, and you are running Vitest with:
11
- - [Vitest UI](/guide/ui)
12
- - or using the [Browser Mode](/guide/browser/) without [headless](/guide/browser/#headless) mode
13
- - or using [HTML Reporter](/guide/reporters#html-reporter)
14
-
15
- ::: tip
16
- This option has no effect if you do not use custom code that relies on this.
17
- :::
@@ -1,85 +0,0 @@
1
- # Configuring Vitest
2
-
3
- If you are using Vite and have a `vite.config` file, Vitest will read it to match with the plugins and setup as your Vite app. If you want to have a different configuration for testing or your main app doesn't rely on Vite specifically, you could either:
4
-
5
- - Create `vitest.config.ts`, which will have the higher priority and will **override** the configuration from `vite.config.ts` (Vitest supports all conventional JS and TS extensions, but doesn't support `json`) - it means all options in your `vite.config` will be **ignored**
6
- - Pass `--config` option to CLI, e.g. `vitest --config ./path/to/vitest.config.ts`
7
- - Use `process.env.VITEST` or `mode` property on `defineConfig` (will be set to `test`/`benchmark` if not overridden with `--mode`) to conditionally apply different configuration in `vite.config.ts`. Note that like any other environment variable, `VITEST` is also exposed on `import.meta.env` in your tests
8
-
9
- To configure `vitest` itself, add `test` property in your Vite config. You'll also need to add a reference to Vitest types using a [triple slash command](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-) at the top of your config file, if you are importing `defineConfig` from `vite` itself.
10
-
11
- If you are not using `vite`, add `defineConfig` imported from `vitest/config` to your config file:
12
-
13
- ```js [vitest.config.js]
14
- import { defineConfig } from 'vitest/config'
15
-
16
- export default defineConfig({
17
- test: {
18
- // ... Specify options here.
19
- },
20
- })
21
- ```
22
-
23
- If you have a `vite` config already, you can add `/// <reference types="vitest/config" />` to include the `test` types:
24
-
25
- ```js [vite.config.js]
26
- /// <reference types="vitest/config" />
27
- import { defineConfig } from 'vite'
28
-
29
- export default defineConfig({
30
- test: {
31
- // ... Specify options here.
32
- },
33
- })
34
- ```
35
-
36
- You can retrieve Vitest's default options to expand them if needed:
37
-
38
- ```js [vitest.config.js]
39
- import { configDefaults, defineConfig } from 'vitest/config'
40
-
41
- export default defineConfig({
42
- test: {
43
- exclude: [...configDefaults.exclude, 'packages/template/*'],
44
- },
45
- })
46
- ```
47
-
48
- When using a separate `vitest.config.js`, you can also extend Vite's options from another config file if needed:
49
-
50
- ```js [vitest.config.js]
51
- import { defineConfig, mergeConfig } from 'vitest/config'
52
- import viteConfig from './vite.config'
53
-
54
- export default mergeConfig(viteConfig, defineConfig({
55
- test: {
56
- exclude: ['packages/template/*'],
57
- },
58
- }))
59
- ```
60
-
61
- If your Vite config is defined as a function, you can define the config like this:
62
-
63
- ```js [vitest.config.js]
64
- import { defineConfig, mergeConfig } from 'vitest/config'
65
- import viteConfig from './vite.config'
66
-
67
- export default defineConfig(configEnv => mergeConfig(
68
- viteConfig(configEnv),
69
- defineConfig({
70
- test: {
71
- exclude: ['packages/template/*'],
72
- },
73
- })
74
- ))
75
- ```
76
-
77
- Since Vitest uses Vite config, you can also use any configuration option from [Vite](https://vitejs.dev/config/). For example, `define` to define global variables, or `resolve.alias` to define aliases - these options should be defined on the top level, _not_ within a `test` property.
78
-
79
- ## Automatic Dependency Installation
80
-
81
- Vitest will prompt you to install certain dependencies if they are not already installed. You can disable this behavior by setting the `VITEST_SKIP_INSTALL_CHECKS=1` environment variable.
82
-
83
- ## Config Options
84
-
85
- Configuration options that are not supported inside a [project](/guide/projects) config have <CRoot /> icon next to them. This means they can only be set in the root Vitest config.
@@ -1,13 +0,0 @@
1
- # isolate
2
-
3
- - **Type:** `boolean`
4
- - **Default:** `true`
5
- - **CLI:** `--no-isolate`, `--isolate=false`
6
-
7
- Run tests in an isolated environment. This option has no effect on `vmThreads` and `vmForks` pools.
8
-
9
- Disabling this option might [improve performance](/guide/improving-performance) if your code doesn't rely on side effects (which is usually true for projects with `node` environment).
10
-
11
- ::: tip
12
- You can disable isolation for specific test files by using Vitest workspaces and disabling isolation per project.
13
- :::
@@ -1,7 +0,0 @@
1
- # logHeapUsage
2
-
3
- - **Type:** `boolean`
4
- - **Default:** `false`
5
- - **CLI:** `--logHeapUsage`, `--logHeapUsage=false`
6
-
7
- Show heap usage after each test. Useful for debugging memory leaks.
@@ -1,9 +0,0 @@
1
- # maxConcurrency
2
-
3
- - **Type:** `number`
4
- - **Default:** `5`
5
- - **CLI:** `--max-concurrency=10`, `--maxConcurrency=10`
6
-
7
- The maximum number of tests and hooks that can run at the same time when using `test.concurrent` or `describe.concurrent`.
8
-
9
- The hook execution order within a single group is also controlled by [`sequence.hooks`](/config/sequence#sequence-hooks). With `sequence.hooks: 'parallel'`, the execution is bounded by the same limit of [`maxConcurrency`](/config/maxconcurrency).
@@ -1,49 +0,0 @@
1
- # maxWorkers
2
-
3
- - **Type:** `number | string`
4
- - **Default:**
5
- - if [`watch`](/config/watch) is disabled, uses all available parallelism
6
- - if [`watch`](/config/watch) is enabled, uses half of all available parallelism
7
-
8
- Defines the maximum concurrency for test workers. Accepts either a number or a percentage string.
9
-
10
- - Number: spawns up to the specified number of workers.
11
- - Percentage string (e.g., "50%"): computes the worker count as the given percentage of the machine’s available parallelism.
12
-
13
- ## Example
14
-
15
- ### Number
16
-
17
- ::: code-group
18
- ```js [vitest.config.js]
19
- import { defineConfig } from 'vitest/config'
20
-
21
- export default defineConfig({
22
- test: {
23
- maxWorkers: 4,
24
- },
25
- })
26
- ```
27
- ```bash [CLI]
28
- vitest --maxWorkers=4
29
- ```
30
- :::
31
-
32
- ### Percent
33
-
34
- ::: code-group
35
- ```js [vitest.config.js]
36
- import { defineConfig } from 'vitest/config'
37
-
38
- export default defineConfig({
39
- test: {
40
- maxWorkers: '50%',
41
- },
42
- })
43
- ```
44
- ```bash [CLI]
45
- vitest --maxWorkers=50%
46
- ```
47
- :::
48
-
49
- Vitest uses [`os.availableParallelism`](https://nodejs.org/api/os.html#osavailableparallelism) to know the maximum amount of parallelism available.
@@ -1,22 +0,0 @@
1
- # mockReset
2
-
3
- - **Type:** `boolean`
4
- - **Default:** `false`
5
-
6
- Should Vitest automatically call [`vi.resetAllMocks()`](/api/vi#vi-resetallmocks) before each test.
7
-
8
- This will clear mock history and reset each implementation.
9
-
10
- ```js [vitest.config.js]
11
- import { defineConfig } from 'vitest/config'
12
-
13
- export default defineConfig({
14
- test: {
15
- mockReset: true,
16
- },
17
- })
18
- ```
19
-
20
- ::: warning
21
- Be aware that this option may cause problems with async [concurrent tests](/api/test#test-concurrent). If enabled, the completion of one test will clear the mock history and implementation for all mocks, including those currently being used by other tests in progress.
22
- :::
@@ -1,7 +0,0 @@
1
- # mode
2
-
3
- - **Type:** `string`
4
- - **CLI:** `--mode=staging`
5
- - **Default:** `'test'`
6
-
7
- Overrides Vite mode.
@@ -1,111 +0,0 @@
1
- # name
2
-
3
- - **Type:**
4
-
5
- ```ts
6
- interface UserConfig {
7
- name?: string | { label: string; color?: LabelColor }
8
- }
9
- ```
10
-
11
- Assign a custom name to the test project or Vitest process. The name will be visible in the CLI and UI, and available in the Node.js API via [`project.name`](/api/advanced/test-project#name).
12
-
13
- The color used by the CLI and UI can be changed by providing an object with a `color` property.
14
-
15
- ## Colors
16
-
17
- The displayed colors depend on your terminal’s color scheme. In the UI, colors match their CSS equivalents.
18
-
19
- - black
20
- - red
21
- - green
22
- - yellow
23
- - blue
24
- - magenta
25
- - cyan
26
- - white
27
-
28
- ## Example
29
-
30
- ::: code-group
31
- ```js [string]
32
- import { defineConfig } from 'vitest/config'
33
-
34
- export default defineConfig({
35
- test: {
36
- name: 'unit',
37
- },
38
- })
39
- ```
40
- ```js [object]
41
- import { defineConfig } from 'vitest/config'
42
-
43
- export default defineConfig({
44
- test: {
45
- name: {
46
- label: 'unit',
47
- color: 'blue',
48
- },
49
- },
50
- })
51
- ```
52
- :::
53
-
54
- This property is mostly useful if you have several projects as it helps distinguish them in your terminal:
55
-
56
- ```js{7,11} [vitest.config.js]
57
- import { defineConfig } from 'vitest/config'
58
-
59
- export default defineConfig({
60
- test: {
61
- projects: [
62
- {
63
- name: 'unit',
64
- include: ['./test/*.unit.test.js'],
65
- },
66
- {
67
- name: 'e2e',
68
- include: ['./test/*.e2e.test.js'],
69
- },
70
- ],
71
- },
72
- })
73
- ```
74
-
75
- ::: tip
76
- Vitest automatically assigns a name when none is provided. Resolution order:
77
-
78
- - If the project is specified by a config file or directory, Vitest uses the package.json's `name` field.
79
- - If there is no `package.json`, Vitest falls back to the project folder's basename.
80
- - If the project is defined inline in the `projects` array (an object), Vitest assigns a numeric name equal to that project's array index (0-based).
81
- :::
82
-
83
- ::: warning
84
- Note that projects cannot have the same name. Vitest will throw an error during the config resolution.
85
- :::
86
-
87
- You can also assign different names to different browser [instances](/config/browser/instances):
88
-
89
- ```js{10,11} [vitest.config.js]
90
- import { defineConfig } from 'vitest/config'
91
- import { playwright } from '@vitest/browser-playwright'
92
-
93
- export default defineConfig({
94
- test: {
95
- browser: {
96
- enabled: true,
97
- provider: playwright(),
98
- instances: [
99
- { browser: 'chromium', name: 'Chrome' },
100
- { browser: 'firefox', name: 'Firefox' },
101
- ],
102
- },
103
- },
104
- })
105
- ```
106
-
107
- ::: tip
108
- Browser instances inherit their parent project's name with the browser name appended in parentheses. For example, a project named `browser` with a chromium instance will be shown as `browser (chromium)`.
109
-
110
- If the parent project has no name, or instances are defined at the root level (not inside a named project), the instance name defaults to the browser value (e.g. `chromium`). To override this behavior, set an explicit `name` on the instance.
111
- :::
@@ -1,25 +0,0 @@
1
- # onConsoleLog <CRoot />
2
-
3
- ```ts
4
- function onConsoleLog(
5
- log: string,
6
- type: 'stdout' | 'stderr',
7
- entity: TestModule | TestSuite | TestCase | undefined,
8
- ): boolean | void
9
- ```
10
-
11
- Custom handler for `console` methods in tests. If you return `false`, Vitest will not print the log to the console. Note that Vitest ignores all other falsy values.
12
-
13
- Can be useful for filtering out logs from third-party libraries.
14
-
15
- ```ts
16
- import { defineConfig } from 'vitest/config'
17
-
18
- export default defineConfig({
19
- test: {
20
- onConsoleLog(log: string, type: 'stdout' | 'stderr'): boolean | void {
21
- return !(log === 'message from third party library' && type === 'stdout')
22
- },
23
- },
24
- })
25
- ```
@@ -1,32 +0,0 @@
1
- # onStackTrace <CRoot />
2
-
3
- - **Type:** `(error: Error, frame: ParsedStack) => boolean | void`
4
-
5
- Apply a filtering function to each frame of each stack trace when handling errors. This does not apply to stack traces printed by [`printConsoleTrace`](/config/printconsoletrace#printconsoletrace). The first argument, `error`, is a `TestError`.
6
-
7
- Can be useful for filtering out stack trace frames from third-party libraries.
8
-
9
- ::: tip
10
- The stack trace's total size is also typically limited by V8's [`Error.stackTraceLimit`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stackTraceLimit) number. You could set this to a high value in your test setup function to prevent stacks from being truncated.
11
- :::
12
-
13
- ```ts
14
- import type { ParsedStack, TestError } from 'vitest'
15
- import { defineConfig } from 'vitest/config'
16
-
17
- export default defineConfig({
18
- test: {
19
- onStackTrace(error: TestError, { file }: ParsedStack): boolean | void {
20
- // If we've encountered a ReferenceError, show the whole stack.
21
- if (error.name === 'ReferenceError') {
22
- return
23
- }
24
-
25
- // Reject all frames from third party libraries.
26
- if (file.includes('node_modules')) {
27
- return false
28
- }
29
- },
30
- },
31
- })
32
- ```