@vitest-agent/mcp 1.0.0 → 1.1.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.
- package/bin/vitest-agent-mcp.js +1 -17
- package/index.d.ts +322 -313
- package/index.js +2 -4
- package/middleware/idempotency.js +1 -1
- package/package.json +2 -2
- package/patterns/_meta.json +67 -0
- package/patterns/authoring-a-custom-vitest-agent-reporter.md +82 -0
- package/patterns/known-issues-and-caveats.md +52 -0
- package/patterns/operating-vitest-agent-as-an-agent.md +62 -0
- package/patterns/running-tests-via-mcp.md +103 -0
- package/patterns/silencing-leaking-output-in-tests.md +91 -0
- package/patterns/testing-effect-schema-definitions.md +71 -0
- package/patterns/testing-effect-services-with-mock-layers.md +63 -0
- package/resources/index.js +16 -5
- package/resources/manifest-schema.js +1 -1
- package/tools/acceptance-metrics.js +1 -1
- package/tools/cache-health.js +1 -1
- package/tools/commit-changes.js +1 -1
- package/tools/configure.js +1 -1
- package/tools/coverage.js +1 -1
- package/tools/errors.js +1 -1
- package/tools/failure-signature-get.js +1 -1
- package/tools/file-coverage.js +1 -1
- package/tools/history.js +1 -1
- package/tools/inventory.js +1 -1
- package/tools/overview.js +1 -1
- package/tools/run-tests.js +15 -3
- package/tools/settings-list.js +1 -1
- package/tools/status.js +1 -1
- package/tools/tdd-artifact.js +1 -1
- package/tools/tdd-task.js +1 -1
- package/tools/test.js +1 -1
- package/tools/trends.js +1 -1
- package/tools/turn-search.js +1 -1
- package/vendor/vitest-docs/ATTRIBUTION.md +5 -0
- package/vendor/vitest-docs/api/advanced/artifacts.md +189 -0
- package/vendor/vitest-docs/api/advanced/metadata.md +68 -0
- package/vendor/vitest-docs/api/advanced/plugin.md +168 -0
- package/vendor/vitest-docs/api/advanced/reporters.md +342 -0
- package/vendor/vitest-docs/api/advanced/runner.md +334 -0
- package/vendor/vitest-docs/api/advanced/test-case.md +302 -0
- package/vendor/vitest-docs/api/advanced/test-collection.md +89 -0
- package/vendor/vitest-docs/api/advanced/test-module.md +140 -0
- package/vendor/vitest-docs/api/advanced/test-project.md +321 -0
- package/vendor/vitest-docs/api/advanced/test-specification.md +96 -0
- package/vendor/vitest-docs/api/advanced/test-suite.md +230 -0
- package/vendor/vitest-docs/api/advanced/vitest.md +684 -0
- package/vendor/vitest-docs/api/assert-type.md +22 -0
- package/vendor/vitest-docs/api/assert.md +1960 -0
- package/vendor/vitest-docs/api/browser/assertions.md +1277 -0
- package/vendor/vitest-docs/api/browser/commands.md +154 -0
- package/vendor/vitest-docs/api/browser/context.md +338 -0
- package/vendor/vitest-docs/api/browser/interactivity.md +681 -0
- package/vendor/vitest-docs/api/browser/locators.md +1171 -0
- package/vendor/vitest-docs/api/browser/react.md +346 -0
- package/vendor/vitest-docs/api/browser/svelte.md +292 -0
- package/vendor/vitest-docs/api/browser/vue.md +222 -0
- package/vendor/vitest-docs/api/describe.md +374 -0
- package/vendor/vitest-docs/api/expect-typeof.md +571 -0
- package/vendor/vitest-docs/api/expect.md +2304 -0
- package/vendor/vitest-docs/api/hooks.md +463 -0
- package/vendor/vitest-docs/api/mock.md +701 -0
- package/vendor/vitest-docs/api/test.md +926 -0
- package/vendor/vitest-docs/api/vi.md +1372 -0
- package/vendor/vitest-docs/config/alias.md +13 -0
- package/vendor/vitest-docs/config/allowonly.md +32 -0
- package/vendor/vitest-docs/config/api.md +27 -0
- package/vendor/vitest-docs/config/attachmentsdir.md +6 -0
- package/vendor/vitest-docs/config/bail.md +9 -0
- package/vendor/vitest-docs/config/benchmark.md +65 -0
- package/vendor/vitest-docs/config/browser/api.md +23 -0
- package/vendor/vitest-docs/config/browser/commands.md +6 -0
- package/vendor/vitest-docs/config/browser/connecttimeout.md +10 -0
- package/vendor/vitest-docs/config/browser/detailspanelposition.md +38 -0
- package/vendor/vitest-docs/config/browser/enabled.md +40 -0
- package/vendor/vitest-docs/config/browser/expect.md +250 -0
- package/vendor/vitest-docs/config/browser/headless.md +7 -0
- package/vendor/vitest-docs/config/browser/instances.md +47 -0
- package/vendor/vitest-docs/config/browser/isolate.md +11 -0
- package/vendor/vitest-docs/config/browser/locators.md +24 -0
- package/vendor/vitest-docs/config/browser/orchestratorscripts.md +39 -0
- package/vendor/vitest-docs/config/browser/playwright.md +214 -0
- package/vendor/vitest-docs/config/browser/preview.md +32 -0
- package/vendor/vitest-docs/config/browser/provider.md +79 -0
- package/vendor/vitest-docs/config/browser/screenshotdirectory.md +6 -0
- package/vendor/vitest-docs/config/browser/screenshotfailures.md +6 -0
- package/vendor/vitest-docs/config/browser/testerhtmlpath.md +5 -0
- package/vendor/vitest-docs/config/browser/trace.md +43 -0
- package/vendor/vitest-docs/config/browser/trackunhandlederrors.md +10 -0
- package/vendor/vitest-docs/config/browser/ui.md +7 -0
- package/vendor/vitest-docs/config/browser/viewport.md +6 -0
- package/vendor/vitest-docs/config/browser/webdriverio.md +64 -0
- package/vendor/vitest-docs/config/cache.md +26 -0
- package/vendor/vitest-docs/config/chaiconfig.md +29 -0
- package/vendor/vitest-docs/config/clearmocks.md +22 -0
- package/vendor/vitest-docs/config/coverage.md +455 -0
- package/vendor/vitest-docs/config/css.md +47 -0
- package/vendor/vitest-docs/config/dangerouslyignoreunhandlederrors.md +23 -0
- package/vendor/vitest-docs/config/deps.md +127 -0
- package/vendor/vitest-docs/config/detectasyncleaks.md +39 -0
- package/vendor/vitest-docs/config/diff.md +96 -0
- package/vendor/vitest-docs/config/dir.md +7 -0
- package/vendor/vitest-docs/config/disableconsoleintercept.md +15 -0
- package/vendor/vitest-docs/config/env.md +5 -0
- package/vendor/vitest-docs/config/environment.md +96 -0
- package/vendor/vitest-docs/config/environmentoptions.md +30 -0
- package/vendor/vitest-docs/config/exclude.md +49 -0
- package/vendor/vitest-docs/config/execargv.md +10 -0
- package/vendor/vitest-docs/config/expandsnapshotdiff.md +7 -0
- package/vendor/vitest-docs/config/expect.md +38 -0
- package/vendor/vitest-docs/config/experimental.md +510 -0
- package/vendor/vitest-docs/config/faketimers.md +51 -0
- package/vendor/vitest-docs/config/fileparallelism.md +11 -0
- package/vendor/vitest-docs/config/forcereruntriggers.md +19 -0
- package/vendor/vitest-docs/config/globals.md +42 -0
- package/vendor/vitest-docs/config/globalsetup.md +72 -0
- package/vendor/vitest-docs/config/hideskippedtests.md +7 -0
- package/vendor/vitest-docs/config/hooktimeout.md +7 -0
- package/vendor/vitest-docs/config/include-source.md +115 -0
- package/vendor/vitest-docs/config/include.md +71 -0
- package/vendor/vitest-docs/config/includetasklocation.md +17 -0
- package/vendor/vitest-docs/config/index.md +85 -0
- package/vendor/vitest-docs/config/isolate.md +13 -0
- package/vendor/vitest-docs/config/logheapusage.md +7 -0
- package/vendor/vitest-docs/config/maxconcurrency.md +9 -0
- package/vendor/vitest-docs/config/maxworkers.md +49 -0
- package/vendor/vitest-docs/config/mockreset.md +22 -0
- package/vendor/vitest-docs/config/mode.md +7 -0
- package/vendor/vitest-docs/config/name.md +111 -0
- package/vendor/vitest-docs/config/onconsolelog.md +25 -0
- package/vendor/vitest-docs/config/onstacktrace.md +32 -0
- package/vendor/vitest-docs/config/onunhandlederror.md +35 -0
- package/vendor/vitest-docs/config/open.md +7 -0
- package/vendor/vitest-docs/config/outputfile.md +7 -0
- package/vendor/vitest-docs/config/passwithnotests.md +7 -0
- package/vendor/vitest-docs/config/pool.md +45 -0
- package/vendor/vitest-docs/config/printconsoletrace.md +6 -0
- package/vendor/vitest-docs/config/projects.md +6 -0
- package/vendor/vitest-docs/config/provide.md +45 -0
- package/vendor/vitest-docs/config/reporters.md +69 -0
- package/vendor/vitest-docs/config/resolvesnapshotpath.md +36 -0
- package/vendor/vitest-docs/config/restoremocks.md +22 -0
- package/vendor/vitest-docs/config/retry.md +140 -0
- package/vendor/vitest-docs/config/root.md +6 -0
- package/vendor/vitest-docs/config/runner.md +6 -0
- package/vendor/vitest-docs/config/sequence.md +158 -0
- package/vendor/vitest-docs/config/server.md +68 -0
- package/vendor/vitest-docs/config/setupfiles.md +40 -0
- package/vendor/vitest-docs/config/silent.md +9 -0
- package/vendor/vitest-docs/config/slowtestthreshold.md +7 -0
- package/vendor/vitest-docs/config/snapshotenvironment.md +27 -0
- package/vendor/vitest-docs/config/snapshotformat.md +28 -0
- package/vendor/vitest-docs/config/snapshotserializers.md +6 -0
- package/vendor/vitest-docs/config/stricttags.md +30 -0
- package/vendor/vitest-docs/config/tags.md +141 -0
- package/vendor/vitest-docs/config/teardowntimeout.md +7 -0
- package/vendor/vitest-docs/config/testnamepattern.md +21 -0
- package/vendor/vitest-docs/config/testtimeout.md +7 -0
- package/vendor/vitest-docs/config/typecheck.md +77 -0
- package/vendor/vitest-docs/config/ui.md +15 -0
- package/vendor/vitest-docs/config/unstubenvs.md +20 -0
- package/vendor/vitest-docs/config/unstubglobals.md +20 -0
- package/vendor/vitest-docs/config/update.md +16 -0
- package/vendor/vitest-docs/config/vmmemorylimit.md +30 -0
- package/vendor/vitest-docs/config/watch.md +11 -0
- package/vendor/vitest-docs/config/watchtriggerpatterns.md +29 -0
- package/vendor/vitest-docs/guide/advanced/index.md +147 -0
- package/vendor/vitest-docs/guide/advanced/pool.md +148 -0
- package/vendor/vitest-docs/guide/advanced/reporters.md +93 -0
- package/vendor/vitest-docs/guide/advanced/tests.md +125 -0
- package/vendor/vitest-docs/guide/browser/aria-snapshots.md +470 -0
- package/vendor/vitest-docs/guide/browser/component-testing.md +571 -0
- package/vendor/vitest-docs/guide/browser/index.md +630 -0
- package/vendor/vitest-docs/guide/browser/multiple-setups.md +121 -0
- package/vendor/vitest-docs/guide/browser/trace-view.md +126 -0
- package/vendor/vitest-docs/guide/browser/visual-regression-testing.md +734 -0
- package/vendor/vitest-docs/guide/cli-generated.md +972 -0
- package/vendor/vitest-docs/guide/cli.md +234 -0
- package/vendor/vitest-docs/guide/common-errors.md +163 -0
- package/vendor/vitest-docs/guide/coverage.md +515 -0
- package/vendor/vitest-docs/guide/debugging.md +127 -0
- package/vendor/vitest-docs/guide/environment.md +101 -0
- package/vendor/vitest-docs/guide/extending-matchers.md +160 -0
- package/vendor/vitest-docs/guide/features.md +310 -0
- package/vendor/vitest-docs/guide/filtering.md +175 -0
- package/vendor/vitest-docs/guide/ide.md +43 -0
- package/vendor/vitest-docs/guide/improving-performance.md +245 -0
- package/vendor/vitest-docs/guide/in-source.md +159 -0
- package/vendor/vitest-docs/guide/index.md +128 -0
- package/vendor/vitest-docs/guide/learn/async.md +147 -0
- package/vendor/vitest-docs/guide/learn/debugging-tests.md +210 -0
- package/vendor/vitest-docs/guide/learn/matchers.md +277 -0
- package/vendor/vitest-docs/guide/learn/mock-functions.md +277 -0
- package/vendor/vitest-docs/guide/learn/setup-teardown.md +240 -0
- package/vendor/vitest-docs/guide/learn/snapshots.md +166 -0
- package/vendor/vitest-docs/guide/learn/testing-in-practice.md +430 -0
- package/vendor/vitest-docs/guide/learn/writing-tests-with-ai.md +127 -0
- package/vendor/vitest-docs/guide/learn/writing-tests.md +231 -0
- package/vendor/vitest-docs/guide/lifecycle.md +379 -0
- package/vendor/vitest-docs/guide/migration.md +863 -0
- package/vendor/vitest-docs/guide/mocking/classes.md +158 -0
- package/vendor/vitest-docs/guide/mocking/dates.md +52 -0
- package/vendor/vitest-docs/guide/mocking/file-system.md +74 -0
- package/vendor/vitest-docs/guide/mocking/functions.md +61 -0
- package/vendor/vitest-docs/guide/mocking/globals.md +20 -0
- package/vendor/vitest-docs/guide/mocking/modules.md +414 -0
- package/vendor/vitest-docs/guide/mocking/requests.md +114 -0
- package/vendor/vitest-docs/guide/mocking/timers.md +48 -0
- package/vendor/vitest-docs/guide/mocking.md +239 -0
- package/vendor/vitest-docs/guide/open-telemetry.md +156 -0
- package/vendor/vitest-docs/guide/parallelism.md +82 -0
- package/vendor/vitest-docs/guide/profiling-test-performance.md +243 -0
- package/vendor/vitest-docs/guide/projects.md +291 -0
- package/vendor/vitest-docs/guide/recipes.md +59 -0
- package/vendor/vitest-docs/guide/reporters.md +723 -0
- package/vendor/vitest-docs/guide/snapshot.md +620 -0
- package/vendor/vitest-docs/guide/test-annotations.md +103 -0
- package/vendor/vitest-docs/guide/test-context.md +902 -0
- package/vendor/vitest-docs/guide/test-tags.md +314 -0
- package/vendor/vitest-docs/guide/testing-types.md +149 -0
- package/vendor/vitest-docs/guide/ui.md +160 -0
- package/vendor/vitest-docs/guide/using-plugins.md +5 -0
- package/vendor/vitest-docs/manifest.json +1691 -0
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
# Coverage
|
|
2
|
+
|
|
3
|
+
Vitest supports Native code coverage via [`v8`](https://v8.dev/blog/javascript-code-coverage) and instrumented code coverage via [`istanbul`](https://istanbul.js.org/).
|
|
4
|
+
|
|
5
|
+
## Coverage Providers
|
|
6
|
+
|
|
7
|
+
Both `v8` and `istanbul` support are optional. By default, `v8` will be used.
|
|
8
|
+
|
|
9
|
+
You can select the coverage tool by setting `test.coverage.provider` to `v8` or `istanbul`:
|
|
10
|
+
|
|
11
|
+
```ts [vitest.config.ts]
|
|
12
|
+
import { defineConfig } from 'vitest/config'
|
|
13
|
+
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
test: {
|
|
16
|
+
coverage: {
|
|
17
|
+
provider: 'v8' // or 'istanbul'
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
When you start the Vitest process, it will prompt you to install the corresponding support package automatically.
|
|
24
|
+
|
|
25
|
+
Or if you prefer to install them manually:
|
|
26
|
+
|
|
27
|
+
::: code-group
|
|
28
|
+
```bash [v8]
|
|
29
|
+
npm i -D @vitest/coverage-v8
|
|
30
|
+
```
|
|
31
|
+
```bash [istanbul]
|
|
32
|
+
npm i -D @vitest/coverage-istanbul
|
|
33
|
+
```
|
|
34
|
+
:::
|
|
35
|
+
|
|
36
|
+
## V8 Provider
|
|
37
|
+
|
|
38
|
+
::: info
|
|
39
|
+
The description of V8 coverage below is Vitest specific and does not apply to other test runners.
|
|
40
|
+
Since `v3.2.0` Vitest has used [AST based coverage remapping](/blog/vitest-3-2#coverage-v8-ast-aware-remapping) for V8 coverage, which produces identical coverage reports to Istanbul.
|
|
41
|
+
|
|
42
|
+
This allows users to have the speed of V8 coverage with accuracy of Istanbul coverage.
|
|
43
|
+
:::
|
|
44
|
+
|
|
45
|
+
By default Vitest uses `'v8'` coverage provider.
|
|
46
|
+
This provider requires Javascript runtime that's implemented on top of [V8 engine](https://v8.dev/), such as NodeJS, Deno or any Chromium based browsers such as Google Chrome.
|
|
47
|
+
|
|
48
|
+
Coverage collection is performed during runtime by instructing V8 using [`node:inspector`](https://nodejs.org/api/inspector.html) and [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/tot/Profiler/) in browsers. User's source files can be executed as-is without any pre-instrumentation steps.
|
|
49
|
+
|
|
50
|
+
- ✅ Recommended option to use
|
|
51
|
+
- ✅ No pre-transpile step. Test files can be executed as-is.
|
|
52
|
+
- ✅ Faster execute times than Istanbul.
|
|
53
|
+
- ✅ Lower memory usage than Istanbul.
|
|
54
|
+
- ✅ Coverage report accuracy is as good as with Istanbul ([since Vitest `v3.2.0`](/blog/vitest-3-2#coverage-v8-ast-aware-remapping)).
|
|
55
|
+
- ⚠️ In some cases can be slower than Istanbul, e.g. when loading lots of different modules. V8 does not support limiting coverage collection to specific modules.
|
|
56
|
+
- ⚠️ There are some minor limitations set by V8 engine. See [`ast-v8-to-istanbul` | Limitations](https://github.com/AriPerkkio/ast-v8-to-istanbul?tab=readme-ov-file#limitations).
|
|
57
|
+
- ❌ Does not work on environments that don't use V8, such as Firefox or Bun. Or on environments that don't expose V8 coverage via profiler, such as Cloudflare Workers.
|
|
58
|
+
|
|
59
|
+
<script setup>
|
|
60
|
+
import ArrowDown from '../.vitepress/components/ArrowDown.vue'
|
|
61
|
+
import Box from '../.vitepress/components/Box.vue'
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<div style="display: flex; flex-direction: column; align-items: center; padding: 2rem 0; max-width: 20rem;">
|
|
65
|
+
<Box>Test file</Box>
|
|
66
|
+
<ArrowDown />
|
|
67
|
+
<Box>Enable V8 runtime coverage collection</Box>
|
|
68
|
+
<ArrowDown />
|
|
69
|
+
<Box>Run file</Box>
|
|
70
|
+
<ArrowDown />
|
|
71
|
+
<Box>Collect coverage results from V8</Box>
|
|
72
|
+
<ArrowDown />
|
|
73
|
+
<Box>Remap coverage results to source files</Box>
|
|
74
|
+
<ArrowDown />
|
|
75
|
+
<Box>Coverage report</Box>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
## Istanbul Provider
|
|
79
|
+
|
|
80
|
+
[Istanbul code coverage tooling](https://istanbul.js.org/) has existed since 2012 and is very well battle-tested.
|
|
81
|
+
This provider works on any Javascript runtime as coverage tracking is done by instrumenting user's source files.
|
|
82
|
+
|
|
83
|
+
In practice, instrumenting source files means adding additional Javascript in user's files:
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
// Simplified example of branch and function coverage counters
|
|
87
|
+
const coverage = { // [!code ++]
|
|
88
|
+
branches: { 1: [0, 0] }, // [!code ++]
|
|
89
|
+
functions: { 1: 0 }, // [!code ++]
|
|
90
|
+
} // [!code ++]
|
|
91
|
+
|
|
92
|
+
export function getUsername(id) {
|
|
93
|
+
// Function coverage increased when this is invoked // [!code ++]
|
|
94
|
+
coverage.functions['1']++ // [!code ++]
|
|
95
|
+
|
|
96
|
+
if (id == null) {
|
|
97
|
+
// Branch coverage increased when this is invoked // [!code ++]
|
|
98
|
+
coverage.branches['1'][0]++ // [!code ++]
|
|
99
|
+
|
|
100
|
+
throw new Error('User ID is required')
|
|
101
|
+
}
|
|
102
|
+
// Implicit else coverage increased when if-statement condition not met // [!code ++]
|
|
103
|
+
coverage.branches['1'][1]++ // [!code ++]
|
|
104
|
+
|
|
105
|
+
return database.getUser(id)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
globalThis.__VITEST_COVERAGE__ ||= {} // [!code ++]
|
|
109
|
+
globalThis.__VITEST_COVERAGE__[filename] = coverage // [!code ++]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- ✅ Works on any Javascript runtime
|
|
113
|
+
- ✅ Widely used and battle-tested for over 13 years.
|
|
114
|
+
- ✅ In some cases faster than V8. Coverage instrumentation can be limited to specific files, as opposed to V8 where all modules are instrumented.
|
|
115
|
+
- ❌ Requires pre-instrumentation step
|
|
116
|
+
- ❌ Execution speed is slower than V8 due to instrumentation overhead
|
|
117
|
+
- ❌ Instrumentation increases file sizes
|
|
118
|
+
- ❌ Memory usage is higher than V8
|
|
119
|
+
|
|
120
|
+
<div style="display: flex; flex-direction: column; align-items: center; padding: 2rem 0; max-width: 20rem;">
|
|
121
|
+
<Box>Test file</Box>
|
|
122
|
+
<ArrowDown />
|
|
123
|
+
<Box>Pre‑instrumentation with Babel</Box>
|
|
124
|
+
<ArrowDown />
|
|
125
|
+
<Box>Run file</Box>
|
|
126
|
+
<ArrowDown />
|
|
127
|
+
<Box>Collect coverage results from Javascript scope</Box>
|
|
128
|
+
<ArrowDown />
|
|
129
|
+
<Box>Remap coverage results to source files</Box>
|
|
130
|
+
<ArrowDown />
|
|
131
|
+
<Box>Coverage report</Box>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
## Coverage Setup
|
|
135
|
+
|
|
136
|
+
::: tip
|
|
137
|
+
All coverage options are listed in [Coverage Config Reference](/config/coverage).
|
|
138
|
+
:::
|
|
139
|
+
|
|
140
|
+
To test with coverage enabled, you can pass the `--coverage` flag in CLI or set `coverage.enabled` in `vitest.config.ts`:
|
|
141
|
+
|
|
142
|
+
::: code-group
|
|
143
|
+
```json [package.json]
|
|
144
|
+
{
|
|
145
|
+
"scripts": {
|
|
146
|
+
"test": "vitest",
|
|
147
|
+
"coverage": "vitest run --coverage"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
```ts [vitest.config.ts]
|
|
152
|
+
import { defineConfig } from 'vitest/config'
|
|
153
|
+
|
|
154
|
+
export default defineConfig({
|
|
155
|
+
test: {
|
|
156
|
+
coverage: {
|
|
157
|
+
enabled: true
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
})
|
|
161
|
+
```
|
|
162
|
+
:::
|
|
163
|
+
|
|
164
|
+
## Including and Excluding Files from Coverage Report
|
|
165
|
+
|
|
166
|
+
You can define what files are shown in coverage report by configuring [`coverage.include`](/config/coverage#coverage-include) and [`coverage.exclude`](/config/coverage#coverage-exclude).
|
|
167
|
+
|
|
168
|
+
By default Vitest will show only files that were imported during test run.
|
|
169
|
+
To include uncovered files in the report, you'll need to configure [`coverage.include`](/config/coverage#coverage-include) with a pattern that will pick your source files:
|
|
170
|
+
|
|
171
|
+
::: code-group
|
|
172
|
+
```ts [vitest.config.ts] {6}
|
|
173
|
+
import { defineConfig } from 'vitest/config'
|
|
174
|
+
|
|
175
|
+
export default defineConfig({
|
|
176
|
+
test: {
|
|
177
|
+
coverage: {
|
|
178
|
+
include: ['src/**/*.{ts,tsx}']
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
```
|
|
183
|
+
```sh [Covered Files]
|
|
184
|
+
├── src
|
|
185
|
+
│ ├── components
|
|
186
|
+
│ │ └── counter.tsx # [!code ++]
|
|
187
|
+
│ ├── mock-data
|
|
188
|
+
│ │ ├── products.json # [!code error]
|
|
189
|
+
│ │ └── users.json # [!code error]
|
|
190
|
+
│ └── utils
|
|
191
|
+
│ ├── formatters.ts # [!code ++]
|
|
192
|
+
│ ├── time.ts # [!code ++]
|
|
193
|
+
│ └── users.ts # [!code ++]
|
|
194
|
+
├── test
|
|
195
|
+
│ └── utils.test.ts # [!code error]
|
|
196
|
+
│
|
|
197
|
+
├── package.json # [!code error]
|
|
198
|
+
├── tsup.config.ts # [!code error]
|
|
199
|
+
└── vitest.config.ts # [!code error]
|
|
200
|
+
```
|
|
201
|
+
:::
|
|
202
|
+
|
|
203
|
+
To exclude files that are matching `coverage.include`, you can define an additional [`coverage.exclude`](/config/coverage#coverage-exclude):
|
|
204
|
+
|
|
205
|
+
::: code-group
|
|
206
|
+
```ts [vitest.config.ts] {7}
|
|
207
|
+
import { defineConfig } from 'vitest/config'
|
|
208
|
+
|
|
209
|
+
export default defineConfig({
|
|
210
|
+
test: {
|
|
211
|
+
coverage: {
|
|
212
|
+
include: ['src/**/*.{ts,tsx}'],
|
|
213
|
+
exclude: ['**/utils/users.ts']
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
```
|
|
218
|
+
```sh [Covered Files]
|
|
219
|
+
├── src
|
|
220
|
+
│ ├── components
|
|
221
|
+
│ │ └── counter.tsx # [!code ++]
|
|
222
|
+
│ ├── mock-data
|
|
223
|
+
│ │ ├── products.json # [!code error]
|
|
224
|
+
│ │ └── users.json # [!code error]
|
|
225
|
+
│ └── utils
|
|
226
|
+
│ ├── formatters.ts # [!code ++]
|
|
227
|
+
│ ├── time.ts # [!code ++]
|
|
228
|
+
│ └── users.ts # [!code error]
|
|
229
|
+
├── test
|
|
230
|
+
│ └── utils.test.ts # [!code error]
|
|
231
|
+
│
|
|
232
|
+
├── package.json # [!code error]
|
|
233
|
+
├── tsup.config.ts # [!code error]
|
|
234
|
+
└── vitest.config.ts # [!code error]
|
|
235
|
+
```
|
|
236
|
+
:::
|
|
237
|
+
|
|
238
|
+
## Custom Coverage Reporter
|
|
239
|
+
|
|
240
|
+
You can use custom coverage reporters by passing either the name of the package or absolute path in `test.coverage.reporter`:
|
|
241
|
+
|
|
242
|
+
```ts [vitest.config.ts]
|
|
243
|
+
import { defineConfig } from 'vitest/config'
|
|
244
|
+
|
|
245
|
+
export default defineConfig({
|
|
246
|
+
test: {
|
|
247
|
+
coverage: {
|
|
248
|
+
reporter: [
|
|
249
|
+
// Specify reporter using name of the NPM package
|
|
250
|
+
['@vitest/custom-coverage-reporter', { someOption: true }],
|
|
251
|
+
|
|
252
|
+
// Specify reporter using local path
|
|
253
|
+
'/absolute/path/to/custom-reporter.cjs',
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
})
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Custom reporters are loaded by Istanbul and must match its reporter interface. See [built-in reporters' implementation](https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib) for reference.
|
|
261
|
+
|
|
262
|
+
```js [custom-reporter.cjs]
|
|
263
|
+
const { ReportBase } = require('istanbul-lib-report')
|
|
264
|
+
|
|
265
|
+
module.exports = class CustomReporter extends ReportBase {
|
|
266
|
+
constructor(opts) {
|
|
267
|
+
super()
|
|
268
|
+
|
|
269
|
+
// Options passed from configuration are available here
|
|
270
|
+
this.file = opts.file
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
onStart(root, context) {
|
|
274
|
+
this.contentWriter = context.writer.writeFile(this.file)
|
|
275
|
+
this.contentWriter.println('Start of custom coverage report')
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
onEnd() {
|
|
279
|
+
this.contentWriter.println('End of custom coverage report')
|
|
280
|
+
this.contentWriter.close()
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Custom Coverage Provider
|
|
286
|
+
|
|
287
|
+
It's also possible to provide your custom coverage provider by passing `'custom'` in `test.coverage.provider`:
|
|
288
|
+
|
|
289
|
+
```ts [vitest.config.ts]
|
|
290
|
+
import { defineConfig } from 'vitest/config'
|
|
291
|
+
|
|
292
|
+
export default defineConfig({
|
|
293
|
+
test: {
|
|
294
|
+
coverage: {
|
|
295
|
+
provider: 'custom',
|
|
296
|
+
customProviderModule: 'my-custom-coverage-provider'
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
})
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
The custom providers require a `customProviderModule` option which is a module name or path where to load the `CoverageProviderModule` from. It must export an object that implements `CoverageProviderModule` as default export:
|
|
303
|
+
|
|
304
|
+
```ts [my-custom-coverage-provider.ts]
|
|
305
|
+
import type {
|
|
306
|
+
CoverageProvider,
|
|
307
|
+
CoverageProviderModule,
|
|
308
|
+
ResolvedCoverageOptions,
|
|
309
|
+
Vitest
|
|
310
|
+
} from 'vitest'
|
|
311
|
+
|
|
312
|
+
const CustomCoverageProviderModule: CoverageProviderModule = {
|
|
313
|
+
getProvider(): CoverageProvider {
|
|
314
|
+
return new CustomCoverageProvider()
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
// Implements rest of the CoverageProviderModule ...
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
class CustomCoverageProvider implements CoverageProvider {
|
|
321
|
+
name = 'custom-coverage-provider'
|
|
322
|
+
options!: ResolvedCoverageOptions
|
|
323
|
+
|
|
324
|
+
initialize(ctx: Vitest) {
|
|
325
|
+
this.options = ctx.config.coverage
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Implements rest of the CoverageProvider ...
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export default CustomCoverageProviderModule
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Please refer to the type definition for more details.
|
|
335
|
+
|
|
336
|
+
## Ignoring Code
|
|
337
|
+
|
|
338
|
+
Both coverage providers have their own ways how to ignore code from coverage reports:
|
|
339
|
+
|
|
340
|
+
- [`v8`](https://github.com/AriPerkkio/ast-v8-to-istanbul?tab=readme-ov-file#ignoring-code)
|
|
341
|
+
- [`istanbul`](https://github.com/istanbuljs/nyc#parsing-hints-ignoring-lines)
|
|
342
|
+
|
|
343
|
+
When using TypeScript the source codes are transpiled using `esbuild`, which strips all comments from the source codes ([esbuild#516](https://github.com/evanw/esbuild/issues/516)).
|
|
344
|
+
Comments which are considered as [legal comments](https://esbuild.github.io/api/#legal-comments) are preserved.
|
|
345
|
+
|
|
346
|
+
You can include a `@preserve` keyword in the ignore hint.
|
|
347
|
+
Beware that these ignore hints may now be included in final production build as well.
|
|
348
|
+
|
|
349
|
+
::: tip
|
|
350
|
+
Follow https://github.com/vitest-dev/vitest/issues/2021 for updates about `@preserve` usage.
|
|
351
|
+
:::
|
|
352
|
+
|
|
353
|
+
```diff
|
|
354
|
+
-/* istanbul ignore if */
|
|
355
|
+
+/* istanbul ignore if -- @preserve */
|
|
356
|
+
if (condition) {
|
|
357
|
+
|
|
358
|
+
-/* v8 ignore if */
|
|
359
|
+
+/* v8 ignore if -- @preserve */
|
|
360
|
+
if (condition) {
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### Examples
|
|
364
|
+
|
|
365
|
+
::: code-group
|
|
366
|
+
|
|
367
|
+
```ts [lines: start/stop]
|
|
368
|
+
/* istanbul ignore start -- @preserve */
|
|
369
|
+
if (parameter) { // [!code error]
|
|
370
|
+
console.log('Ignored') // [!code error]
|
|
371
|
+
} // [!code error]
|
|
372
|
+
else { // [!code error]
|
|
373
|
+
console.log('Ignored') // [!code error]
|
|
374
|
+
} // [!code error]
|
|
375
|
+
/* istanbul ignore stop -- @preserve */
|
|
376
|
+
|
|
377
|
+
console.log('Included')
|
|
378
|
+
|
|
379
|
+
/* v8 ignore start -- @preserve */
|
|
380
|
+
if (parameter) { // [!code error]
|
|
381
|
+
console.log('Ignored') // [!code error]
|
|
382
|
+
} // [!code error]
|
|
383
|
+
else { // [!code error]
|
|
384
|
+
console.log('Ignored') // [!code error]
|
|
385
|
+
} // [!code error]
|
|
386
|
+
/* v8 ignore stop -- @preserve */
|
|
387
|
+
|
|
388
|
+
console.log('Included')
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
```ts [if else]
|
|
392
|
+
/* v8 ignore if -- @preserve */
|
|
393
|
+
if (parameter) { // [!code error]
|
|
394
|
+
console.log('Ignored') // [!code error]
|
|
395
|
+
} // [!code error]
|
|
396
|
+
else {
|
|
397
|
+
console.log('Included')
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/* v8 ignore else -- @preserve */
|
|
401
|
+
if (parameter) {
|
|
402
|
+
console.log('Included')
|
|
403
|
+
}
|
|
404
|
+
else { // [!code error]
|
|
405
|
+
console.log('Ignored') // [!code error]
|
|
406
|
+
} // [!code error]
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
```ts [next node]
|
|
410
|
+
/* v8 ignore next -- @preserve */
|
|
411
|
+
console.log('Ignored') // [!code error]
|
|
412
|
+
console.log('Included')
|
|
413
|
+
|
|
414
|
+
/* v8 ignore next -- @preserve */
|
|
415
|
+
function ignored() { // [!code error]
|
|
416
|
+
console.log('all') // [!code error]
|
|
417
|
+
// [!code error]
|
|
418
|
+
console.log('lines') // [!code error]
|
|
419
|
+
// [!code error]
|
|
420
|
+
console.log('are') // [!code error]
|
|
421
|
+
// [!code error]
|
|
422
|
+
console.log('ignored') // [!code error]
|
|
423
|
+
} // [!code error]
|
|
424
|
+
|
|
425
|
+
/* v8 ignore next -- @preserve */
|
|
426
|
+
class Ignored { // [!code error]
|
|
427
|
+
ignored() {} // [!code error]
|
|
428
|
+
alsoIgnored() {} // [!code error]
|
|
429
|
+
} // [!code error]
|
|
430
|
+
|
|
431
|
+
/* v8 ignore next -- @preserve */
|
|
432
|
+
condition // [!code error]
|
|
433
|
+
? console.log('ignored') // [!code error]
|
|
434
|
+
: console.log('also ignored') // [!code error]
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
```ts [try catch]
|
|
438
|
+
/* v8 ignore next -- @preserve */
|
|
439
|
+
try { // [!code error]
|
|
440
|
+
console.log('Ignored') // [!code error]
|
|
441
|
+
} // [!code error]
|
|
442
|
+
catch (error) { // [!code error]
|
|
443
|
+
console.log('Ignored') // [!code error]
|
|
444
|
+
} // [!code error]
|
|
445
|
+
|
|
446
|
+
try {
|
|
447
|
+
console.log('Included')
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
/* v8 ignore next -- @preserve */
|
|
451
|
+
console.log('Ignored') // [!code error]
|
|
452
|
+
/* v8 ignore next -- @preserve */
|
|
453
|
+
console.log('Ignored') // [!code error]
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Requires rolldown-vite due to esbuild's lack of support.
|
|
457
|
+
// See https://vite.dev/guide/rolldown.html#how-to-try-rolldown
|
|
458
|
+
try {
|
|
459
|
+
console.log('Included')
|
|
460
|
+
}
|
|
461
|
+
catch (error) /* v8 ignore next */ { // [!code error]
|
|
462
|
+
console.log('Ignored') // [!code error]
|
|
463
|
+
} // [!code error]
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
```ts [switch case]
|
|
467
|
+
switch (type) {
|
|
468
|
+
case 1:
|
|
469
|
+
return 'Included'
|
|
470
|
+
|
|
471
|
+
/* v8 ignore next -- @preserve */
|
|
472
|
+
case 2: // [!code error]
|
|
473
|
+
return 'Ignored' // [!code error]
|
|
474
|
+
|
|
475
|
+
case 3:
|
|
476
|
+
return 'Included'
|
|
477
|
+
|
|
478
|
+
/* v8 ignore next -- @preserve */
|
|
479
|
+
default: // [!code error]
|
|
480
|
+
return 'Ignored' // [!code error]
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
```ts [whole file]
|
|
485
|
+
/* v8 ignore file -- @preserve */
|
|
486
|
+
export function ignored() { // [!code error]
|
|
487
|
+
return 'Whole file is ignored'// [!code error]
|
|
488
|
+
}// [!code error]
|
|
489
|
+
```
|
|
490
|
+
:::
|
|
491
|
+
|
|
492
|
+
## Coverage Performance
|
|
493
|
+
|
|
494
|
+
If code coverage generation is slow on your project, see [Profiling Test Performance | Code coverage](/guide/profiling-test-performance.html#code-coverage).
|
|
495
|
+
|
|
496
|
+
## Vitest UI
|
|
497
|
+
|
|
498
|
+
You can check your coverage report in [Vitest UI](/guide/ui) and [HTML reporter](/guide/reporters.html#html-reporter).
|
|
499
|
+
|
|
500
|
+
This is integrated with builtin coverage reporters with HTML output (`html`, `html-spa`, and `lcov` reporters). `html` reporter is enabled by default and this works out of the box. To integrate with custom reporters, you can configure [`coverage.htmlDir`](/config/coverage#coverage-htmldir).
|
|
501
|
+
|
|
502
|
+
<img alt="html coverage activation in Vitest UI" img-light src="/vitest-ui-show-coverage-light.png">
|
|
503
|
+
<img alt="html coverage activation in Vitest UI" img-dark src="/vitest-ui-show-coverage-dark.png">
|
|
504
|
+
|
|
505
|
+
<img alt="html coverage in Vitest UI" img-light src="/ui-coverage-1-light.png">
|
|
506
|
+
<img alt="html coverage in Vitest UI" img-dark src="/ui-coverage-1-dark.png">
|
|
507
|
+
|
|
508
|
+
## Coverage in Agent Environments
|
|
509
|
+
|
|
510
|
+
When Vitest detects it is running inside an AI coding agent, it automatically adjusts the default `text` reporter to reduce output and minimize token usage:
|
|
511
|
+
|
|
512
|
+
- `skipFull: true` is set on the `text` reporter, so files with 100% coverage are omitted from the terminal output.
|
|
513
|
+
- The [`text-summary`](/config/coverage#coverage-reporter) reporter is added automatically, so the agent always sees a concise totals table even when `skipFull` hides all individual files.
|
|
514
|
+
|
|
515
|
+
These adjustments only apply when the `text` reporter is already part of the active reporter list (it is included in the default). Explicitly configured reporters are never removed.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Debugging
|
|
2
|
+
|
|
3
|
+
:::tip
|
|
4
|
+
When debugging tests you might want to use following options:
|
|
5
|
+
|
|
6
|
+
- [`--test-timeout=0`](/guide/cli#testtimeout) to prevent tests from timing out when stopping at breakpoints
|
|
7
|
+
- [`--no-file-parallelism`](/guide/cli#fileparallelism) to prevent test files from running parallel
|
|
8
|
+
|
|
9
|
+
:::
|
|
10
|
+
|
|
11
|
+
## VS Code
|
|
12
|
+
|
|
13
|
+
Quick way to debug tests in VS Code is via `JavaScript Debug Terminal`. Open a new `JavaScript Debug Terminal` and run `npm run test` or `vitest` directly. *this works with any code run in Node, so will work with most JS testing frameworks*
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
You can also add a dedicated launch configuration to debug a test file in VS Code:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
22
|
+
"version": "0.2.0",
|
|
23
|
+
"configurations": [
|
|
24
|
+
{
|
|
25
|
+
"type": "node",
|
|
26
|
+
"request": "launch",
|
|
27
|
+
"name": "Debug Current Test File",
|
|
28
|
+
"autoAttachChildProcesses": true,
|
|
29
|
+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
|
|
30
|
+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
|
|
31
|
+
"args": ["run", "${relativeFile}"],
|
|
32
|
+
"smartStep": true,
|
|
33
|
+
"console": "integratedTerminal"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Then in the debug tab, ensure 'Debug Current Test File' is selected. You can then open the test file you want to debug and press F5 to start debugging.
|
|
40
|
+
|
|
41
|
+
### Browser mode
|
|
42
|
+
|
|
43
|
+
To debug [Vitest Browser Mode](/guide/browser/index.md), pass `--inspect` or `--inspect-brk` in CLI or define it in your Vitest configuration:
|
|
44
|
+
|
|
45
|
+
::: code-group
|
|
46
|
+
```bash [CLI]
|
|
47
|
+
vitest --inspect-brk --browser --no-file-parallelism
|
|
48
|
+
```
|
|
49
|
+
```ts [vitest.config.js]
|
|
50
|
+
import { defineConfig } from 'vitest/config'
|
|
51
|
+
import { playwright } from '@vitest/browser-playwright'
|
|
52
|
+
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
test: {
|
|
55
|
+
inspectBrk: true,
|
|
56
|
+
fileParallelism: false,
|
|
57
|
+
browser: {
|
|
58
|
+
provider: playwright(),
|
|
59
|
+
instances: [{ browser: 'chromium' }]
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
:::
|
|
65
|
+
|
|
66
|
+
By default Vitest will use port `9229` as debugging port. You can overwrite it with by passing value in `--inspect-brk`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
vitest --inspect-brk=127.0.0.1:3000 --browser --no-file-parallelism
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Use following [VSCode Compound configuration](https://code.visualstudio.com/docs/editor/debugging#_compound-launch-configurations) for launching Vitest and attaching debugger in the browser:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"version": "0.2.0",
|
|
77
|
+
"configurations": [
|
|
78
|
+
{
|
|
79
|
+
"type": "node",
|
|
80
|
+
"request": "launch",
|
|
81
|
+
"name": "Run Vitest Browser",
|
|
82
|
+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
|
|
83
|
+
"console": "integratedTerminal",
|
|
84
|
+
"args": ["--inspect-brk", "--browser", "--no-file-parallelism"]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"type": "chrome",
|
|
88
|
+
"request": "attach",
|
|
89
|
+
"name": "Attach to Vitest Browser",
|
|
90
|
+
"port": 9229
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"compounds": [
|
|
94
|
+
{
|
|
95
|
+
"name": "Debug Vitest Browser",
|
|
96
|
+
"configurations": ["Attach to Vitest Browser", "Run Vitest Browser"],
|
|
97
|
+
"stopAll": true
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## IntelliJ IDEA
|
|
104
|
+
|
|
105
|
+
Create a [vitest](https://www.jetbrains.com/help/idea/vitest.html#createRunConfigVitest) run configuration. Use the following settings to run all tests in debug mode:
|
|
106
|
+
|
|
107
|
+
Setting | Value
|
|
108
|
+
--- | ---
|
|
109
|
+
Working directory | `/path/to/your-project-root`
|
|
110
|
+
|
|
111
|
+
Then run this configuration in debug mode. The IDE will stop at JS/TS breakpoints set in the editor.
|
|
112
|
+
|
|
113
|
+
## Node Inspector, e.g. Chrome DevTools
|
|
114
|
+
|
|
115
|
+
Vitest also supports debugging tests without IDEs. However this requires that tests are not run parallel. Use one of the following commands to launch Vitest.
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
# To run in a single worker
|
|
119
|
+
vitest --inspect-brk --no-file-parallelism
|
|
120
|
+
|
|
121
|
+
# To run in browser mode
|
|
122
|
+
vitest --inspect-brk --browser --no-file-parallelism
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Once Vitest starts it will stop execution and wait for you to open developer tools that can connect to [Node.js inspector](https://nodejs.org/en/docs/guides/debugging-getting-started/). You can use Chrome DevTools for this by opening `chrome://inspect` on browser.
|
|
126
|
+
|
|
127
|
+
In watch mode you can keep the debugger open during test re-runs by using the `--isolate false` options.
|