You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/coverage.md
+4
Original file line number
Diff line number
Diff line change
@@ -215,6 +215,10 @@ if (condition) {
215
215
216
216
To see all configurable options for coverage, see the [coverage Config Reference](https://vitest.dev/config/#coverage).
217
217
218
+
## Coverage performance
219
+
220
+
If code coverage generation is slow on your project, see [Profiling Test Performance | Code coverage](/guide/profiling-test-performance.html#code-coverage).
221
+
218
222
## Vitest UI
219
223
220
224
You can check your coverage report in [Vitest UI](/guide/ui).
If code coverage generation is slow on your project you can use `DEBUG=vitest:coverage` environment variable to enable performance logging.
184
+
185
+
```bash
186
+
$ DEBUG=vitest:coverage vitest --run --coverage
187
+
188
+
RUN v3.1.1 /x/vitest-example
189
+
190
+
vitest:coverage Reading coverage results 2/2
191
+
vitest:coverage Converting 1/2
192
+
vitest:coverage 4 ms /x/src/multiply.ts
193
+
vitest:coverage Converting 2/2
194
+
vitest:coverage 552 ms /x/src/add.ts
195
+
vitest:coverage Uncovered files 1/2
196
+
vitest:coverage File "/x/src/large-file.ts" is taking longer than 3s # [!code error]
197
+
vitest:coverage 3027 ms /x/src/large-file.ts
198
+
vitest:coverage Uncovered files 2/2
199
+
vitest:coverage 4 ms /x/src/untested-file.ts
200
+
vitest:coverage Generate coverage total time 3521 ms
201
+
```
202
+
203
+
This profiling approach is great for detecting large files that are accidentally picked by coverage providers.
204
+
For example if your configuration is accidentally including large built minified Javascript files in code coverage, they should appear in logs.
205
+
In these cases you might want to adjust your [`coverage.include`](/config/#coverage-include) and [`coverage.exclude`](/config/#coverage-exclude) options.
206
+
181
207
## Inspecting profiling records
182
208
183
209
You can inspect the contents of `*.cpuprofile` and `*.heapprofile` with various tools. See list below for examples.
0 commit comments