@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,455 +0,0 @@
1
- # coverage <CRoot /> {#coverage}
2
-
3
- You can use [`v8`](/guide/coverage.html#v8-provider), [`istanbul`](/guide/coverage.html#istanbul-provider) or [a custom coverage solution](/guide/coverage#custom-coverage-provider) for coverage collection.
4
-
5
- You can provide coverage options to CLI with dot notation:
6
-
7
- ```sh
8
- npx vitest --coverage.enabled --coverage.provider=istanbul
9
- ```
10
-
11
- ::: warning
12
- If you are using coverage options with dot notation, don't forget to specify `--coverage.enabled`. Do not provide a single `--coverage` option in that case.
13
- :::
14
-
15
- ## coverage.provider
16
-
17
- - **Type:** `'v8' | 'istanbul' | 'custom'`
18
- - **Default:** `'v8'`
19
- - **CLI:** `--coverage.provider=<provider>`
20
-
21
- Use `provider` to select the tool for coverage collection.
22
-
23
- ## coverage.enabled
24
-
25
- - **Type:** `boolean`
26
- - **Default:** `false`
27
- - **Available for providers:** `'v8' | 'istanbul'`
28
- - **CLI:** `--coverage.enabled`, `--coverage.enabled=false`
29
-
30
- Enables coverage collection. Can be overridden using `--coverage` CLI option.
31
-
32
- ## coverage.include
33
-
34
- - **Type:** `string[]`
35
- - **Default:** Files that were imported during test run
36
- - **Available for providers:** `'v8' | 'istanbul'`
37
- - **CLI:** `--coverage.include=<pattern>`, `--coverage.include=<pattern1> --coverage.include=<pattern2>`
38
-
39
- List of files included in coverage as glob patterns. By default only files covered by tests are included.
40
-
41
- It is recommended to pass file extensions in the pattern.
42
-
43
- See [Including and excluding files from coverage report](/guide/coverage.html#including-and-excluding-files-from-coverage-report) for examples.
44
-
45
- ## coverage.exclude
46
-
47
- - **Type:** `string[]`
48
- - **Default:** : `[]`
49
- - **Available for providers:** `'v8' | 'istanbul'`
50
- - **CLI:** `--coverage.exclude=<path>`, `--coverage.exclude=<path1> --coverage.exclude=<path2>`
51
-
52
- List of files excluded from coverage as glob patterns.
53
-
54
- See [Including and excluding files from coverage report](/guide/coverage.html#including-and-excluding-files-from-coverage-report) for examples.
55
-
56
- ## coverage.clean
57
-
58
- - **Type:** `boolean`
59
- - **Default:** `true`
60
- - **Available for providers:** `'v8' | 'istanbul'`
61
- - **CLI:** `--coverage.clean`, `--coverage.clean=false`
62
-
63
- Clean coverage results before running tests.
64
-
65
- ## coverage.cleanOnRerun
66
-
67
- - **Type:** `boolean`
68
- - **Default:** `true`
69
- - **Available for providers:** `'v8' | 'istanbul'`
70
- - **CLI:** `--coverage.cleanOnRerun`, `--coverage.cleanOnRerun=false`
71
-
72
- Clean coverage report on watch rerun. Set to `false` to preserve coverage results from previous run in watch mode.
73
-
74
- ## coverage.reportsDirectory
75
-
76
- - **Type:** `string`
77
- - **Default:** `'./coverage'`
78
- - **Available for providers:** `'v8' | 'istanbul'`
79
- - **CLI:** `--coverage.reportsDirectory=<path>`
80
-
81
- ::: warning
82
- Vitest will delete this directory before running tests if `coverage.clean` is enabled (default value).
83
- :::
84
-
85
- Directory to write coverage report to.
86
-
87
- ## coverage.reporter
88
-
89
- - **Type:** `string | string[] | [string, {}][]`
90
- - **Default:** `['text', 'html', 'clover', 'json']`
91
- - **Available for providers:** `'v8' | 'istanbul'`
92
- - **CLI:** `--coverage.reporter=<reporter>`, `--coverage.reporter=<reporter1> --coverage.reporter=<reporter2>`
93
-
94
- Coverage reporters to use. See [istanbul documentation](https://istanbul.js.org/docs/advanced/alternative-reporters/) for detailed list of all reporters. See [`@types/istanbul-reports`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/276d95e4304b3670eaf6e8e5a7ea9e265a14e338/types/istanbul-reports/index.d.ts) for details about reporter specific options.
95
-
96
- The reporter has three different types:
97
-
98
- - A single reporter: `{ reporter: 'html' }`
99
- - Multiple reporters without options: `{ reporter: ['html', 'json'] }`
100
- - A single or multiple reporters with reporter options:
101
- <!-- eslint-skip -->
102
- ```ts
103
- {
104
- reporter: [
105
- ['lcov', { 'projectRoot': './src' }],
106
- ['json', { 'file': 'coverage.json' }],
107
- ['text']
108
- ]
109
- }
110
- ```
111
-
112
- You can also pass custom coverage reporters. See [Guide - Custom Coverage Reporter](/guide/coverage#custom-coverage-reporter) for more information.
113
-
114
- <!-- eslint-skip -->
115
- ```ts
116
- {
117
- reporter: [
118
- // Specify reporter using name of the NPM package
119
- '@vitest/custom-coverage-reporter',
120
- ['@vitest/custom-coverage-reporter', { someOption: true }],
121
-
122
- // Specify reporter using local path
123
- '/absolute/path/to/custom-reporter.cjs',
124
- ['/absolute/path/to/custom-reporter.cjs', { someOption: true }],
125
- ]
126
- }
127
- ```
128
-
129
- You can check your coverage report in Vitest UI: check [Vitest UI Coverage](/guide/coverage#vitest-ui) for more details.
130
-
131
- ::: tip AI coding agents
132
- When Vitest detects it is running inside an AI coding agent, it automatically adds the `text-summary` reporter and sets `skipFull: true` on the `text` reporter to reduce output and minimize token usage.
133
- :::
134
-
135
- ## coverage.reportOnFailure {#coverage-reportonfailure}
136
-
137
- - **Type:** `boolean`
138
- - **Default:** `false`
139
- - **Available for providers:** `'v8' | 'istanbul'`
140
- - **CLI:** `--coverage.reportOnFailure`, `--coverage.reportOnFailure=false`
141
-
142
- Generate coverage report even when tests fail.
143
-
144
- ## coverage.allowExternal
145
-
146
- - **Type:** `boolean`
147
- - **Default:** `false`
148
- - **Available for providers:** `'v8' | 'istanbul'`
149
- - **CLI:** `--coverage.allowExternal`, `--coverage.allowExternal=false`
150
-
151
- Collect coverage of files outside the [project `root`](/config/root).
152
-
153
- ## coverage.excludeAfterRemap
154
-
155
- - **Type:** `boolean`
156
- - **Default:** `false`
157
- - **Available for providers:** `'v8' | 'istanbul'`
158
- - **CLI:** `--coverage.excludeAfterRemap`, `--coverage.excludeAfterRemap=false`
159
-
160
- Apply exclusions again after coverage has been remapped to original sources.
161
- This is useful when your source files are transpiled and may contain source maps of non-source files.
162
-
163
- Use this option when you are seeing files that show up in report even if they match your `coverage.exclude` patterns.
164
-
165
- ## coverage.skipFull
166
-
167
- - **Type:** `boolean`
168
- - **Default:** `false`
169
- - **Available for providers:** `'v8' | 'istanbul'`
170
- - **CLI:** `--coverage.skipFull`, `--coverage.skipFull=false`
171
-
172
- Do not show files with 100% statement, branch, and function coverage.
173
-
174
- ## coverage.thresholds
175
-
176
- Options for coverage thresholds.
177
-
178
- If a threshold is set to a positive number, it will be interpreted as the minimum percentage of coverage required. For example, setting the lines threshold to `90` means that 90% of lines must be covered.
179
-
180
- If a threshold is set to a negative number, it will be treated as the maximum number of uncovered items allowed. For example, setting the lines threshold to `-10` means that no more than 10 lines may be uncovered.
181
-
182
- <!-- eslint-skip -->
183
- ```ts
184
- {
185
- coverage: {
186
- thresholds: {
187
- // Requires 90% function coverage
188
- functions: 90,
189
-
190
- // Require that no more than 10 lines are uncovered
191
- lines: -10,
192
- }
193
- }
194
- }
195
- ```
196
-
197
- ### coverage.thresholds.lines
198
-
199
- - **Type:** `number`
200
- - **Available for providers:** `'v8' | 'istanbul'`
201
- - **CLI:** `--coverage.thresholds.lines=<number>`
202
-
203
- Global threshold for lines.
204
-
205
- ### coverage.thresholds.functions
206
-
207
- - **Type:** `number`
208
- - **Available for providers:** `'v8' | 'istanbul'`
209
- - **CLI:** `--coverage.thresholds.functions=<number>`
210
-
211
- Global threshold for functions.
212
-
213
- ### coverage.thresholds.branches
214
-
215
- - **Type:** `number`
216
- - **Available for providers:** `'v8' | 'istanbul'`
217
- - **CLI:** `--coverage.thresholds.branches=<number>`
218
-
219
- Global threshold for branches.
220
-
221
- ### coverage.thresholds.statements
222
-
223
- - **Type:** `number`
224
- - **Available for providers:** `'v8' | 'istanbul'`
225
- - **CLI:** `--coverage.thresholds.statements=<number>`
226
-
227
- Global threshold for statements.
228
-
229
- ### coverage.thresholds.perFile
230
-
231
- - **Type:** `boolean`
232
- - **Default:** `false`
233
- - **Available for providers:** `'v8' | 'istanbul'`
234
- - **CLI:** `--coverage.thresholds.perFile`, `--coverage.thresholds.perFile=false`
235
-
236
- Check thresholds per file.
237
-
238
- ### coverage.thresholds.autoUpdate
239
-
240
- - **Type:** `boolean | function`
241
- - **Default:** `false`
242
- - **Available for providers:** `'v8' | 'istanbul'`
243
- - **CLI:** `--coverage.thresholds.autoUpdate=<boolean>`
244
-
245
- Update all threshold values `lines`, `functions`, `branches` and `statements` to configuration file when current coverage is better than the configured thresholds.
246
- This option helps to maintain thresholds when coverage is improved.
247
-
248
- You can also pass a function for formatting the updated threshold values:
249
-
250
- <!-- eslint-skip -->
251
- ```ts
252
- {
253
- coverage: {
254
- thresholds: {
255
- // Update thresholds without decimals
256
- autoUpdate: (newThreshold) => Math.floor(newThreshold),
257
-
258
- // 95.85 -> 95
259
- functions: 95,
260
- }
261
- }
262
- }
263
- ```
264
-
265
- ### coverage.thresholds.100
266
-
267
- - **Type:** `boolean`
268
- - **Default:** `false`
269
- - **Available for providers:** `'v8' | 'istanbul'`
270
- - **CLI:** `--coverage.thresholds.100`, `--coverage.thresholds.100=false`
271
-
272
- Sets global thresholds to 100.
273
- Shortcut for `--coverage.thresholds.lines 100 --coverage.thresholds.functions 100 --coverage.thresholds.branches 100 --coverage.thresholds.statements 100`.
274
-
275
- ### coverage.thresholds[glob-pattern]
276
-
277
- - **Type:** `{ statements?: number functions?: number branches?: number lines?: number }`
278
- - **Default:** `undefined`
279
- - **Available for providers:** `'v8' | 'istanbul'`
280
-
281
- Sets thresholds for files matching the glob pattern.
282
-
283
- ::: tip NOTE
284
- Vitest counts all files, including those covered by glob-patterns, into the global coverage thresholds.
285
- This is different from Jest behavior.
286
- :::
287
-
288
- <!-- eslint-skip -->
289
- ```ts
290
- {
291
- coverage: {
292
- thresholds: {
293
- // Thresholds for all files
294
- functions: 95,
295
- branches: 70,
296
-
297
- // Thresholds for matching glob pattern
298
- 'src/utils/**.ts': {
299
- statements: 95,
300
- functions: 90,
301
- branches: 85,
302
- lines: 80,
303
- },
304
-
305
- // Files matching this pattern will only have lines thresholds set.
306
- // Global thresholds are not inherited.
307
- '**/math.ts': {
308
- lines: 100,
309
- }
310
- }
311
- }
312
- }
313
- ```
314
-
315
- ### coverage.thresholds[glob-pattern].100
316
-
317
- - **Type:** `boolean`
318
- - **Default:** `false`
319
- - **Available for providers:** `'v8' | 'istanbul'`
320
-
321
- Sets thresholds to 100 for files matching the glob pattern.
322
-
323
- <!-- eslint-skip -->
324
- ```ts
325
- {
326
- coverage: {
327
- thresholds: {
328
- // Thresholds for all files
329
- functions: 95,
330
- branches: 70,
331
-
332
- // Thresholds for matching glob pattern
333
- 'src/utils/**.ts': { 100: true },
334
- '**/math.ts': { 100: true }
335
- }
336
- }
337
- }
338
- ```
339
-
340
- ## coverage.ignoreClassMethods
341
-
342
- - **Type:** `string[]`
343
- - **Default:** `[]`
344
- - **Available for providers:** `'v8' | 'istanbul'`
345
- - **CLI:** `--coverage.ignoreClassMethods=<method>`
346
-
347
- Set to array of class method names to ignore for coverage.
348
- See [istanbul documentation](https://github.com/istanbuljs/nyc#ignoring-methods) for more information.
349
-
350
- ## coverage.watermarks
351
-
352
- - **Type:**
353
- <!-- eslint-skip -->
354
- ```ts
355
- {
356
- statements?: [number, number],
357
- functions?: [number, number],
358
- branches?: [number, number],
359
- lines?: [number, number]
360
- }
361
- ```
362
-
363
- - **Default:**
364
- <!-- eslint-skip -->
365
- ```ts
366
- {
367
- statements: [50, 80],
368
- functions: [50, 80],
369
- branches: [50, 80],
370
- lines: [50, 80]
371
- }
372
- ```
373
-
374
- - **Available for providers:** `'v8' | 'istanbul'`
375
- - **CLI:** `--coverage.watermarks.statements=50,80`, `--coverage.watermarks.branches=50,80`
376
-
377
- Watermarks for statements, lines, branches and functions. See [istanbul documentation](https://github.com/istanbuljs/nyc#high-and-low-watermarks) for more information.
378
-
379
- ## coverage.processingConcurrency
380
-
381
- - **Type:** `boolean`
382
- - **Default:** `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
383
- - **Available for providers:** `'v8' | 'istanbul'`
384
- - **CLI:** `--coverage.processingConcurrency=<number>`
385
-
386
- Concurrency limit used when processing the coverage results.
387
-
388
- ## coverage.instrumenter <Version type="experimental">4.1.5</Version> {#coverage-instrumenter}
389
-
390
- - **Type:** `(options: InstrumenterOptions) => CoverageInstrumenter`
391
- - **Available for providers:** `'istanbul'`
392
-
393
- Factory for a custom instrumenter to use in place of the default `istanbul-lib-instrument`. Vitest calls the factory once during initialization and reuses the returned instrumenter for every file. The rest of the Istanbul pipeline (collection, merging, reporting) is unchanged.
394
-
395
- The factory receives an `InstrumenterOptions` object with Vitest's runtime coverage settings, and must return an object implementing the `CoverageInstrumenter` interface. Both types are exported from `vitest/node`.
396
-
397
- <!-- eslint-skip -->
398
- ```ts
399
- interface InstrumenterOptions {
400
- coverageVariable: string
401
- coverageGlobalScope: string
402
- coverageGlobalScopeFunc: boolean
403
- ignoreClassMethods: string[]
404
- }
405
-
406
- interface CoverageInstrumenter {
407
- instrumentSync: (code: string, filename: string, inputSourceMap?: any) => string
408
- lastSourceMap: () => any
409
- lastFileCoverage: () => any
410
- }
411
- ```
412
-
413
- <!-- eslint-skip -->
414
- ```ts
415
- import { defineConfig } from 'vitest/config'
416
- import { createInstrumenter } from '@vitest/some-custom-instrumenter'
417
-
418
- export default defineConfig({
419
- test: {
420
- coverage: {
421
- provider: 'istanbul',
422
- instrumenter: options => createInstrumenter(options),
423
- }
424
- }
425
- })
426
- ```
427
-
428
- ## coverage.customProviderModule
429
-
430
- - **Type:** `string`
431
- - **Available for providers:** `'custom'`
432
- - **CLI:** `--coverage.customProviderModule=<path or module name>`
433
-
434
- Specifies the module name or path for the custom coverage provider module. See [Guide - Custom Coverage Provider](/guide/coverage#custom-coverage-provider) for more information.
435
-
436
- ## coverage.htmlDir
437
-
438
- - **Type:** `string`
439
- - **Default:** Automatically inferred from `html`, `html-spa`, or `lcov` coverage reporters
440
- - **CLI:** `--coverage.htmlDir=<path>`
441
-
442
- Directory of HTML coverage output to be served in [Vitest UI](/guide/ui) and [HTML reporter](/guide/reporters.html#html-reporter).
443
-
444
- This is automatically configured when using builtin coverage reporters that produce HTML output (`html`, `html-spa`, and `lcov`). Use this option to override with a custom coverage reporting location when using custom coverage reporters.
445
-
446
- Note that setting this option does not change where coverage HTML report is generated. Configure the `coverage.reporter` option to change the directory instead.
447
-
448
- ## coverage.changed
449
-
450
- - **Type:** `boolean | string`
451
- - **Default:** `false` (inherits from `test.changed`)
452
- - **Available for providers:** `'v8' | 'istanbul'`
453
- - **CLI:** `--coverage.changed`, `--coverage.changed=<commit/branch>`
454
-
455
- Collect coverage only for files changed since a specified commit or branch. When set to `true`, it uses staged and unstaged changes.
@@ -1,47 +0,0 @@
1
- # css
2
-
3
- - **Type:** `boolean | { include?, exclude?, modules? }`
4
-
5
- Configure if CSS should be processed. When excluded, CSS files will be replaced with empty strings to bypass the subsequent processing. CSS Modules will return a proxy to not affect runtime.
6
-
7
- ::: warning
8
- This option is not applied to [browser tests](/guide/browser/).
9
- :::
10
-
11
- ## css.include
12
-
13
- - **Type:** `RegExp | RegExp[]`
14
- - **Default:** `[]`
15
-
16
- RegExp pattern for files that should return actual CSS and will be processed by Vite pipeline.
17
-
18
- :::tip
19
- To process all CSS files, use `/.+/`.
20
- :::
21
-
22
- ## css.exclude
23
-
24
- - **Type:** `RegExp | RegExp[]`
25
- - **Default:** `[]`
26
-
27
- RegExp pattern for files that will return an empty CSS file.
28
-
29
- ## css.modules
30
-
31
- - **Type:** `{ classNameStrategy? }`
32
- - **Default:** `{}`
33
-
34
- ### css.modules.classNameStrategy
35
-
36
- - **Type:** `'stable' | 'scoped' | 'non-scoped'`
37
- - **Default:** `'stable'`
38
-
39
- If you decide to process CSS files, you can configure if class names inside CSS modules should be scoped. You can choose one of the options:
40
-
41
- - `stable`: class names will be generated as `_${name}_${hashedFilename}`, which means that generated class will stay the same, if CSS content is changed, but will change, if the name of the file is modified, or file is moved to another folder. This setting is useful, if you use snapshot feature.
42
- - `scoped`: class names will be generated as usual, respecting `css.modules.generateScopedName` method, if you have one and CSS processing is enabled. By default, filename will be generated as `_${name}_${hash}`, where hash includes filename and content of the file.
43
- - `non-scoped`: class names will not be hashed.
44
-
45
- ::: warning
46
- By default, Vitest exports a proxy, bypassing CSS Modules processing. If you rely on CSS properties on your classes, you have to enable CSS processing using `include` option.
47
- :::
@@ -1,23 +0,0 @@
1
- # dangerouslyIgnoreUnhandledErrors <CRoot />
2
-
3
- - **Type:** `boolean`
4
- - **Default:** `false`
5
- - **CLI:**
6
- - `--dangerouslyIgnoreUnhandledErrors`
7
- - `--dangerouslyIgnoreUnhandledErrors=false`
8
-
9
- If this option is set to `true`, Vitest will not fail the test run if there are unhandled errors. Note that built-in reporters will still report them.
10
-
11
- If you want to filter out certain errors conditionally, use [`onUnhandledError`](/config/onunhandlederror) callback instead.
12
-
13
- ## Example
14
-
15
- ```js [vitest.config.js]
16
- import { defineConfig } from 'vitest/config'
17
-
18
- export default defineConfig({
19
- test: {
20
- dangerouslyIgnoreUnhandledErrors: true,
21
- },
22
- })
23
- ```
@@ -1,127 +0,0 @@
1
- # deps
2
-
3
- - **Type:** `{ optimizer?, ... }`
4
-
5
- Handling for dependencies resolution.
6
-
7
- ## deps.optimizer {#deps-optimizer}
8
-
9
- - **Type:** `{ ssr?, client? }`
10
- - **See also:** [Dep Optimization Options](https://vitejs.dev/config/dep-optimization-options.html)
11
-
12
- Enable dependency optimization. If you have a lot of tests, this might improve their performance.
13
-
14
- When Vitest encounters the external library listed in `include`, it will be bundled into a single file using esbuild and imported as a whole module. This is good for several reasons:
15
-
16
- - Importing packages with a lot of imports is expensive. By bundling them into one file we can save a lot of time
17
- - Importing UI libraries is expensive because they are not meant to run inside Node.js
18
- - Your `alias` configuration is now respected inside bundled packages
19
- - Code in your tests is running closer to how it's running in the browser
20
-
21
- Be aware that only packages in `deps.optimizer?.[mode].include` option are bundled (some plugins populate this automatically, like Svelte). You can read more about available options in [Vite](https://vitejs.dev/config/dep-optimization-options.html) docs (Vitest doesn't support `disable` and `noDiscovery` options). By default, Vitest uses `optimizer.client` for `jsdom` and `happy-dom` environments, and `optimizer.ssr` for `node` and `edge` environments.
22
-
23
- This options also inherits your `optimizeDeps` configuration (for web Vitest will extend `optimizeDeps`, for ssr - `ssr.optimizeDeps`). If you redefine `include`/`exclude` option in `deps.optimizer` it will extend your `optimizeDeps` when running tests. Vitest automatically removes the same options from `include`, if they are listed in `exclude`.
24
-
25
- ::: tip
26
- You will not be able to edit your `node_modules` code for debugging, since the code is actually located in your `cacheDir` or `test.cache.dir` directory. If you want to debug with `console.log` statements, edit it directly or force rebundling with `deps.optimizer?.[mode].force` option.
27
- :::
28
-
29
- ### deps.optimizer.{mode}.enabled
30
-
31
- - **Type:** `boolean`
32
- - **Default:** `false`
33
-
34
- Enable dependency optimization.
35
-
36
- ## deps.client {#deps-client}
37
-
38
- - **Type:** `{ transformAssets?, ... }`
39
-
40
- Options that are applied to external files when the environment is set to `client`. By default, `jsdom` and `happy-dom` use `client` environment, while `node` and `edge` environments use `ssr`, so these options will have no affect on files inside those environments.
41
-
42
- Usually, files inside `node_modules` are externalized, but these options also affect files in [`server.deps.external`](/config/server#server-deps-external).
43
-
44
- ### deps.client.transformAssets
45
-
46
- - **Type:** `boolean`
47
- - **Default:** `true`
48
-
49
- Should Vitest process assets (.png, .svg, .jpg, etc) files and resolve them like Vite does in the browser.
50
-
51
- This module will have a default export equal to the path to the asset, if no query is specified.
52
-
53
- ::: warning
54
- At the moment, this option only works with [`vmThreads`](/config/pool#vmthreads) and [`vmForks`](/config/pool#vmforks) pools.
55
- :::
56
-
57
- ### deps.client.transformCss
58
-
59
- - **Type:** `boolean`
60
- - **Default:** `true`
61
-
62
- Should Vitest process CSS (.css, .scss, .sass, etc) files and resolve them like Vite does in the browser.
63
-
64
- If CSS files are disabled with [`css`](/config/css) options, this option will just silence `ERR_UNKNOWN_FILE_EXTENSION` errors.
65
-
66
- ::: warning
67
- At the moment, this option only works with [`vmThreads`](/config/pool#vmthreads) and [`vmForks`](/config/pool#vmforks) pools.
68
- :::
69
-
70
- ### deps.client.transformGlobPattern
71
-
72
- - **Type:** `RegExp | RegExp[]`
73
- - **Default:** `[]`
74
-
75
- Regexp pattern to match external files that should be transformed.
76
-
77
- By default, files inside `node_modules` are externalized and not transformed, unless it's CSS or an asset, and corresponding option is not disabled.
78
-
79
- ::: warning
80
- At the moment, this option only works with [`vmThreads`](/config/pool#vmthreads) and [`vmForks`](/config/pool#vmforks) pools.
81
- :::
82
-
83
- ## deps.interopDefault
84
-
85
- - **Type:** `boolean`
86
- - **Default:** `true`
87
-
88
- Interpret CJS module's default as named exports. Some dependencies only bundle CJS modules and don't use named exports that Node.js can statically analyze when a package is imported using `import` syntax instead of `require`. When importing such dependencies in Node environment using named exports, you will see this error:
89
-
90
- ```
91
- import { read } from 'fs-jetpack';
92
- ^^^^
93
- SyntaxError: Named export 'read' not found. The requested module 'fs-jetpack' is a CommonJS module, which may not support all module.exports as named exports.
94
- CommonJS modules can always be imported via the default export.
95
- ```
96
-
97
- Vitest doesn't do static analysis, and cannot fail before your running code, so you will most likely see this error when running tests, if this feature is disabled:
98
-
99
- ```
100
- TypeError: createAsyncThunk is not a function
101
- TypeError: default is not a function
102
- ```
103
-
104
- By default, Vitest assumes you are using a bundler to bypass this and will not fail, but you can disable this behaviour manually, if your code is not processed.
105
-
106
- ## deps.moduleDirectories
107
-
108
- - **Type:** `string[]`
109
- - **Default:** `['node_modules']`
110
-
111
- A list of directories that should be treated as module directories. This config option affects the behavior of [`vi.mock`](/api/vi#vi-mock): when no factory is provided and the path of what you are mocking matches one of the `moduleDirectories` values, Vitest will try to resolve the mock by looking for a `__mocks__` folder in the [root](/config/root) of the project.
112
-
113
- This option will also affect if a file should be treated as a module when externalizing dependencies. By default, Vitest imports external modules with native Node.js bypassing Vite transformation step.
114
-
115
- Setting this option will _override_ the default, if you wish to still search `node_modules` for packages include it along with any other options:
116
-
117
- ```ts
118
- import { defineConfig } from 'vitest/config'
119
-
120
- export default defineConfig({
121
- test: {
122
- deps: {
123
- moduleDirectories: ['node_modules', path.resolve('../../packages')],
124
- }
125
- },
126
- })
127
- ```
@@ -1,39 +0,0 @@
1
- # detectAsyncLeaks
2
-
3
- - **Type:** `boolean`
4
- - **CLI:** `--detectAsyncLeaks`, `--detect-async-leaks`
5
- - **Default:** `false`
6
-
7
- ::: warning
8
- Enabling this option will make your tests run much slower. Use only when debugging or developing tests.
9
- :::
10
-
11
- Detect asynchronous resources leaking from the test file.
12
- Uses [`node:async_hooks`](https://nodejs.org/api/async_hooks.html) to track creation of async resources. If a resource is not cleaned up, it will be logged after tests have finished.
13
-
14
- For example if your code has `setTimeout` calls that execute the callback after tests have finished, you will see following error:
15
-
16
- ```sh
17
- ⎯⎯⎯⎯⎯⎯⎯⎯ Async Leaks 1 ⎯⎯⎯⎯⎯⎯⎯⎯
18
-
19
- Timeout leaking in test/checkout-screen.test.tsx
20
- 26|
21
- 27| useEffect(() => {
22
- 28| setTimeout(() => setWindowWidth(window.innerWidth), 150)
23
- | ^
24
- 29| })
25
- 30|
26
- ```
27
-
28
- To fix this, you'll need to make sure your code cleans the timeout properly:
29
-
30
- ```js
31
- useEffect(() => {
32
- setTimeout(() => setWindowWidth(window.innerWidth), 150) // [!code --]
33
- const timeout = setTimeout(() => setWindowWidth(window.innerWidth), 150) // [!code ++]
34
-
35
- return function cleanup() { // [!code ++]
36
- clearTimeout(timeout) // [!code ++]
37
- } // [!code ++]
38
- })
39
- ```