Skip to content

Commit e24cd9b

Browse files
feat(ui): add html coverage (#3071)
Co-authored-by: Vladimir Sheremet <[email protected]>
1 parent 78bad4a commit e24cd9b

File tree

23 files changed

+216
-20
lines changed

23 files changed

+216
-20
lines changed

.eslintrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
}
2424
]
2525
}
26+
},
27+
{
28+
// these files define vitest as peer dependency
29+
"files": "packages/{coverage-*,ui,browser}/**/*.*",
30+
"rules": {
31+
"no-restricted-imports": [
32+
"error",
33+
{
34+
"paths": ["path"]
35+
}
36+
]
37+
}
2638
}
2739
]
2840
}

docs/config/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,8 @@ The reporter has three different types:
776776
}
777777
```
778778

779+
Since Vitest 0.31.0, you can check your coverage report in Vitest UI: check [Vitest UI Coverage](/guide/coverage#vitest-ui) for more details.
780+
779781
#### coverage.skipFull
780782

781783
- **Type:** `boolean`

docs/guide/coverage.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,15 @@ if (condition) {
164164
## Other Options
165165
166166
To see all configurable options for coverage, see the [coverage Config Reference](https://vitest.dev/config/#coverage).
167+
168+
## Vitest UI
169+
170+
Since Vitest 0.31.0, you can check your coverage report in [Vitest UI](./ui).
171+
172+
If you have configured coverage reporters, don't forget to add `html` reporter to the list, Vitest UI will only enable html coverage report if it is present.
173+
174+
<img alt="html coverage activation in Vitest UI" img-light src="/vitest-ui-show-coverage-light.png">
175+
<img alt="html coverage activation in Vitest UI" img-dark src="/vitest-ui-show-coverage-dark.png">
176+
177+
<img alt="html coverage in Vitest UI" img-light src="/vitest-ui-coverage-light.png">
178+
<img alt="html coverage in Vitest UI" img-dark src="/vitest-ui-coverage-dark.png">

docs/guide/ui.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export default {
3434
}
3535
```
3636

37+
Since Vitest 0.31.0, you can check your coverage report in Vitest UI: check [Vitest UI Coverage](/guide/coverage#vitest-ui) for more details.
38+
3739
::: warning
3840
If you still want to see how your tests are running in real time in the terminal, don't forget to add `default` reporter to `reporters` option: `['default', 'html']`.
3941
:::
76.1 KB
Loading
77.2 KB
Loading
3.49 KB
Loading
3.48 KB
Loading

packages/browser/src/client/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { createClient } from '@vitest/ws-client'
2-
// eslint-disable-next-line no-restricted-imports
32
import type { ResolvedConfig } from 'vitest'
43
import type { CancelReason, VitestRunner } from '@vitest/runner'
54
import { createBrowserRunner } from './runner'

packages/coverage-c8/src/provider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { provider } from 'std-env'
99
import type { EncodedSourceMap } from 'vite-node'
1010
import { coverageConfigDefaults } from 'vitest/config'
1111
import { BaseCoverageProvider } from 'vitest/coverage'
12-
// eslint-disable-next-line no-restricted-imports
1312
import type { AfterSuiteRunMeta, CoverageC8Options, CoverageProvider, ReportContext, ResolvedCoverageOptions } from 'vitest'
1413
import type { Vitest } from 'vitest/node'
1514
import type { Report } from 'c8'

0 commit comments

Comments
 (0)