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
-[Chai](https://www.chaijs.com/) built-in for assertions, with [Jest expect](https://jestjs.io/docs/expect) compatible APIs.
37
37
-[Smart & instant watch mode](https://vitest.dev/guide/features.html#watch-mode), like HMR for tests!
38
-
-[Native code coverage](https://vitest.dev/guide/features.html#coverage) via [c8](https://github.com/bcoe/c8) or [`istanbul`](https://istanbul.js.org/).
38
+
-[Native code coverage](https://vitest.dev/guide/features.html#coverage) via [`v8`](https://v8.dev/blog/javascript-code-coverage) or [`istanbul`](https://istanbul.js.org/).
39
39
-[Tinyspy](https://github.com/tinylibs/tinyspy) built-in for mocking, stubbing, and spies.
40
40
-[JSDOM](https://github.com/jsdom/jsdom) and [happy-dom](https://github.com/capricorn86/happy-dom) for DOM and browser API mocking
<ListItem><atarget="_blank"href="https://github.com/tinylibs/tinyspy"rel="noopener noreferrer">Tinyspy</a> built-in for mocking</ListItem>
24
24
<ListItem><atarget="_blank"href="https://github.com/capricorn86/happy-dom"rel="noopener noreferrer">happy-dom</a> or <atarget="_blank"href="https://github.com/jsdom/jsdom"rel="noopener noreferrer">jsdom</a> for DOM mocking</ListItem>
25
-
<ListItem>Code coverage via <atarget="_blank"href="https://github.com/bcoe/c8"rel="noopener noreferrer">c8</a> or <atarget="_blank"href="https://istanbul.js.org/"rel="noopener noreferrer">istanbul</a></ListItem>
25
+
<ListItem>Code coverage via <atarget="_blank"href="https://v8.dev/blog/javascript-code-coverage"rel="noopener noreferrer">v8</a> or <atarget="_blank"href="https://istanbul.js.org/"rel="noopener noreferrer">istanbul</a></ListItem>
Copy file name to clipboardExpand all lines: docs/config/index.md
+26-22Lines changed: 26 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -665,7 +665,11 @@ Isolate environment for each test file. Does not work if you disable [`--threads
665
665
666
666
### coverage<NonProjectOption />
667
667
668
-
You can use [`c8`](https://github.com/bcoe/c8), [`istanbul`](https://istanbul.js.org/) or [a custom coverage solution](/guide/coverage#custom-coverage-provider) for coverage collection.
668
+
You can use [`v8`](https://v8.dev/blog/javascript-code-coverage), [`istanbul`](https://istanbul.js.org/) or [a custom coverage solution](/guide/coverage#custom-coverage-provider) for coverage collection.
669
+
670
+
::: info
671
+
The `c8` provider is being replaced by the `v8` provider. It will be deprecated in the next major version.
672
+
:::
669
673
670
674
You can provide coverage options to CLI with dot notation:
671
675
@@ -679,8 +683,8 @@ If you are using coverage options with dot notation, don't forget to specify `--
679
683
680
684
#### coverage.provider
681
685
682
-
-**Type:**`'c8' | 'istanbul' | 'custom'`
683
-
-**Default:**`'c8'`
686
+
-**Type:**`'c8' | 'v8' | 'istanbul' | 'custom'`
687
+
-**Default:**`'v8'`
684
688
-**CLI:**`--coverage.provider=<provider>`
685
689
686
690
Use `provider` to select the tool for coverage collection.
@@ -689,7 +693,7 @@ Use `provider` to select the tool for coverage collection.
689
693
690
694
-**Type:**`boolean`
691
695
-**Default:**`false`
692
-
-**Available for providers:**`'c8' | 'istanbul'`
696
+
-**Available for providers:**`'c8' | 'v8' | 'istanbul'`
Coverage reporters to use. See [istanbul documentation](https://istanbul.js.org/docs/advanced/alternative-reporters/) for detailed list of all reporters. See [`@types/istanbul-reporter`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/276d95e4304b3670eaf6e8e5a7ea9e265a14e338/types/istanbul-reports/index.d.ts) for details about reporter specific options.
@@ -801,7 +805,7 @@ Since Vitest 0.31.0, you can check your coverage report in Vitest UI: check [Vit
801
805
802
806
-**Type:**`boolean`
803
807
-**Default:**`true`
804
-
-**Available for providers:**`'c8' | 'istanbul'`
808
+
-**Available for providers:**`'c8' | 'v8' | 'istanbul'`
Update threshold values `lines`, `functions`, `branches` and `statements` to configuration file when current coverage is above the configured thresholds.
@@ -839,7 +843,7 @@ This option helps to maintain thresholds when coverage is improved.
839
843
#### coverage.lines
840
844
841
845
-**Type:**`number`
842
-
-**Available for providers:**`'c8' | 'istanbul'`
846
+
-**Available for providers:**`'c8' | 'v8' | 'istanbul'`
843
847
-**CLI:**`--coverage.lines=<number>`
844
848
845
849
Threshold for lines.
@@ -848,7 +852,7 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#coverage-threshol
848
852
#### coverage.functions
849
853
850
854
-**Type:**`number`
851
-
-**Available for providers:**`'c8' | 'istanbul'`
855
+
-**Available for providers:**`'c8' | 'v8' | 'istanbul'`
852
856
-**CLI:**`--coverage.functions=<number>`
853
857
854
858
Threshold for functions.
@@ -857,7 +861,7 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#coverage-threshol
857
861
#### coverage.branches
858
862
859
863
-**Type:**`number`
860
-
-**Available for providers:**`'c8' | 'istanbul'`
864
+
-**Available for providers:**`'c8' | 'v8' | 'istanbul'`
861
865
-**CLI:**`--coverage.branches=<number>`
862
866
863
867
Threshold for branches.
@@ -866,7 +870,7 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#coverage-threshol
866
870
#### coverage.statements
867
871
868
872
-**Type:**`number`
869
-
-**Available for providers:**`'c8' | 'istanbul'`
873
+
-**Available for providers:**`'c8' | 'v8' | 'istanbul'`
870
874
-**CLI:**`--coverage.statements=<number>`
871
875
872
876
Threshold for statements.
@@ -903,7 +907,7 @@ Specifies the directories that are used when `--all` is enabled.
@@ -942,7 +946,7 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#ignoring-methods)
942
946
}
943
947
```
944
948
945
-
-**Available for providers:**`'c8' | 'istanbul'`
949
+
-**Available for providers:**`'c8' | 'v8' | 'istanbul'`
946
950
947
951
Watermarks for statements, lines, branches and functions. See [istanbul documentation](https://github.com/istanbuljs/nyc#high-and-low-watermarks) for more information.
Copy file name to clipboardExpand all lines: docs/guide/coverage.md
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,21 @@ title: Coverage | Guide
4
4
5
5
# Coverage
6
6
7
-
Vitest supports Native code coverage via [`c8`](https://github.com/bcoe/c8) and instrumented code coverage via [`istanbul`](https://istanbul.js.org/).
7
+
Vitest supports Native code coverage via [`v8`](https://v8.dev/blog/javascript-code-coverage) and instrumented code coverage via [`istanbul`](https://istanbul.js.org/).
8
+
9
+
:::info
10
+
The `c8` provider is being replaced by the [`v8`](https://v8.dev/blog/javascript-code-coverage) provider. It will be deprecated in the next major version.
11
+
:::
8
12
9
13
## Coverage Providers
10
14
11
15
:::tip
12
16
Since Vitest v0.22.0
13
17
:::
14
18
15
-
Both `c8` and `istanbul` support are optional. By default, `c8` will be used.
19
+
Both `v8` and `istanbul` support are optional. By default, `v8` will be used.
16
20
17
-
You can select the coverage tool by setting `test.coverage.provider` to either `c8` or `istanbul`:
21
+
You can select the coverage tool by setting `test.coverage.provider` to `v8` or `istanbul`:
18
22
19
23
```ts
20
24
// vite.config.ts
@@ -23,7 +27,7 @@ import { defineConfig } from 'vitest/config'
23
27
exportdefaultdefineConfig({
24
28
test: {
25
29
coverage: {
26
-
provider: 'istanbul'// or 'c8'
30
+
provider: 'istanbul'// or 'v8'
27
31
},
28
32
},
29
33
})
@@ -34,8 +38,8 @@ When you start the Vitest process, it will prompt you to install the correspondi
34
38
Or if you prefer to install them manually:
35
39
36
40
```bash
37
-
# For c8
38
-
npm i -D @vitest/coverage-c8
41
+
# For v8
42
+
npm i -D @vitest/coverage-v8
39
43
40
44
# For istanbul
41
45
npm i -D @vitest/coverage-istanbul
@@ -138,7 +142,7 @@ export default defineConfig({
138
142
139
143
Both coverage providers have their own ways how to ignore code from coverage reports:
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)).
@@ -153,7 +157,7 @@ Beware that these ignore hints may now be included in final production build as
153
157
if (condition) {
154
158
```
155
159
156
-
For `c8` this does not cause any issues. You can use `c8 ignore` comments with Typescript as usual:
160
+
For `v8` this does not cause any issues. You can use `c8 ignore` comments with Typescript as usual:
Copy file name to clipboardExpand all lines: docs/guide/features.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,7 @@ Learn more at [Mocking](/guide/mocking).
143
143
144
144
## Coverage
145
145
146
-
Vitest supports Native code coverage via [`c8`](https://github.com/bcoe/c8) and instrumented code coverage via [`istanbul`](https://istanbul.js.org/).
146
+
Vitest supports Native code coverage via [`v8`](https://v8.dev/blog/javascript-code-coverage) and instrumented code coverage via [`istanbul`](https://istanbul.js.org/).
0 commit comments