vitest 0.0.31 → 0.0.32

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/README.gh.md CHANGED
@@ -22,6 +22,7 @@ A blazing fast unit test framework powered by Vite.
22
22
  - ESM friendly
23
23
  - Out-of-box TypeScript support
24
24
  - Suite and Test filtering (skip, only, todo)
25
+ - [Test coverage](#coverage)
25
26
 
26
27
  ```ts
27
28
  import { it, describe, expect, assert } from 'vitest'
@@ -90,7 +91,7 @@ export default defineConfig({
90
91
 
91
92
  To get TypeScript working with the global APIs, add `vitest/global` to the `types` filed in your `tsconfig.json`
92
93
 
93
- ```json
94
+ ```jsonc
94
95
  // tsconfig.json
95
96
  {
96
97
  "compilerOptions": {
@@ -124,6 +125,31 @@ $ vitest -w
124
125
 
125
126
  Vitest smartly searches the module graph and only rerun the related tests (just like how HMR works in Vite!).
126
127
 
128
+ ## Coverage
129
+
130
+ Vitest works perfectly with [c8](https://github.com/bcoe/c8)
131
+
132
+ ```bash
133
+ $ c8 vitest
134
+ ```
135
+
136
+ ```json
137
+ {
138
+ "scripts": {
139
+ "test": "vitest",
140
+ "coverage": "c8 vitest"
141
+ }
142
+ }
143
+ ```
144
+
145
+ For convenience, we also provide a shorthand for passing `--coverage` option to CLI, which will wrap the process with `c8` for you. Note when using the shorthand, you will lose the ability to pass additional options to `c8`.
146
+
147
+ ```bash
148
+ $ vitest --coverage
149
+ ```
150
+
151
+ For more configuration avaliable, please refer to [c8](https://github.com/bcoe/c8)'s documentation.
152
+
127
153
  ## Filtering
128
154
 
129
155
  ### CLI
@@ -200,19 +226,6 @@ describe('suite', () => {
200
226
  })
201
227
  ```
202
228
 
203
- ## TODO
204
-
205
- - [x] Reporter & Better output
206
- - [x] Task filter
207
- - [x] Mock
208
- - [x] Global Mode & Types
209
- - [ ] Parallel Executing
210
- - [x] CLI Help
211
- - [x] JSDom
212
- - [x] Watch
213
- - [ ] Source Map
214
- - [ ] Coverage
215
-
216
229
  ## Sponsors
217
230
 
218
231
  <p align="center">
package/bin/vitest.mjs CHANGED
@@ -1,4 +1,16 @@
1
1
  #!/usr/bin/env node
2
- 'use strict'
3
2
 
4
- import '../dist/node/cli.js'
3
+ import { fileURLToPath } from 'url'
4
+ import { resolve } from 'path'
5
+
6
+ const argv = process.argv.slice(2)
7
+ const filename = fileURLToPath(import.meta.url)
8
+ const entry = resolve(filename, '../../dist/node/cli.js')
9
+
10
+ if (argv.includes('--coverage')) {
11
+ process.argv.splice(2, 0, process.argv[0], entry)
12
+ await import('c8/bin/c8.js')
13
+ }
14
+ else {
15
+ await import('../dist/node/cli.js')
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -48,6 +48,7 @@
48
48
  "test:core": "node bin/vitest.mjs --dev -r test/core",
49
49
  "test:vue": "node bin/vitest.mjs --dev -r test/vue",
50
50
  "test:react": "node bin/vitest.mjs --dev -r test/react",
51
+ "coverage": "node bin/vitest.mjs --dev -r test/core --coverage",
51
52
  "watch": "tsc -p src/tsconfig.json --watch"
52
53
  },
53
54
  "dependencies": {
@@ -55,6 +56,7 @@
55
56
  "@jest/test-result": "^27.4.2",
56
57
  "@types/chai": "^4.2.22",
57
58
  "@types/sinon-chai": "^3.2.6",
59
+ "c8": "^7.10.0",
58
60
  "chai": "^4.3.4",
59
61
  "chai-subset": "^1.6.0",
60
62
  "diff": "^5.0.0",