File tree 4 files changed +37
-3
lines changed
4 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ A good place to start is reading the base command README and looking at the comm
94
94
95
95
### Testing
96
96
97
- This repo uses [ ava ] ( https://github.com/avajs/ava ) for testing. Unit tests are in the ` tests/unit ` folder and
97
+ This repo uses [ vitest ] ( https://github.com/vitest-dev/vitest ) for testing. Unit tests are in the ` tests/unit ` folder and
98
98
integration tests are in the ` tests/integration ` folder. We use this convention since we split tests across multiple CI
99
99
machines to speed up CI time. You can read about it more [ here] ( https://github.com/netlify/cli/issues/4178 ) .
100
100
@@ -105,6 +105,32 @@ We also test for a few other things:
105
105
- Test coverage
106
106
- Must work with Windows + Unix environments.
107
107
108
+ #### Debugging tests
109
+
110
+ To run a single test file you can do:
111
+
112
+ ```
113
+ npm exec vitest -- run tests/unit/tests/unit/lib/account.test.mjs
114
+ ```
115
+
116
+ To run a single test you can either use ` test.only ` inside the test file and ran the above command or run this:
117
+
118
+ ```
119
+ npm exec vitest -- run tests/unit/tests/unit/lib/account.test.mjs -t 'test name'
120
+ ```
121
+
122
+ Some of the tests actually start the CLI in a subprocess and therefore sometimes underlying errors are not visible in
123
+ the tests when they fail. By default the output of the subprocess is not forwarded to the main process to keep the cli
124
+ output clean. To debug test failures like this you can set the environment variable ` DEBUG_TESTS=true ` and the
125
+ subprocess will pipe it's output to the main process for you to see.
126
+
127
+ When ` DEBUG_TESTS ` is set the vitest reporter will be set to ` tap ` so the test output won't interfere with the debug
128
+ output.
129
+
130
+ ```
131
+ DEBUG_TESTS=true npm exec vitest -- run tests/unit/tests/unit/lib/account.test.mjs -t 'test name'
132
+ ```
133
+
108
134
### Lint docs per Netlify style guide
109
135
110
136
1 . [ Install vale] ( https://docs.errata.ai/vale/install )
Original file line number Diff line number Diff line change 150
150
" cesare soldini <[email protected] >" ,
151
151
" chris (fool) mccraw (http://twitter.com/fool)" ,
152
152
" dustincrogers" ,
153
+ " eddie" ,
153
154
" ehmicky (https://twitter.com/ehmicky)" ,
154
155
" internal tools netlibot" ,
155
- " just toby" ,
156
156
" kvn-shn" ,
157
157
" netlibot (https://www.netlify.com)" ,
158
158
" nikoladev" ,
211
211
"test:init:eleventy-deps" : " npm ci --prefix tests/integration/eleventy-site --no-audit" ,
212
212
"test:init:hugo-deps" : " npm ci --prefix tests/integration/hugo-site --no-audit" ,
213
213
"test:dev:ava" : " ava --verbose" ,
214
- "test:dev:vitest" : " vitest run" ,
214
+ "test:dev:vitest" : " vitest run tests/unit/ && vitest run tests/integration " ,
215
215
"test:ci:ava:integration" : " c8 -r json ava --concurrency 1 --no-worker-threads tests/integration/" ,
216
216
"test:ci:vitest:unit" : " vitest run --coverage tests/unit/" ,
217
217
"test:ci:vitest:integration" : " vitest run --coverage --no-threads tests/integration/" ,
Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ const startServer = async ({
44
44
getExecaOptions ( { cwd, env } ) ,
45
45
)
46
46
47
+ if ( process . env . DEBUG_TESTS ) {
48
+ ps . stderr . pipe ( process . stderr )
49
+ ps . stdout . pipe ( process . stdout )
50
+ }
51
+
47
52
const promptHistory = [ ]
48
53
49
54
if ( prompt ) {
Original file line number Diff line number Diff line change 1
1
/// <reference types="vitest" />
2
+ import process from 'process'
3
+
2
4
import { defineConfig } from 'vite'
3
5
4
6
export default defineConfig ( {
@@ -9,6 +11,7 @@ export default defineConfig({
9
11
external : [ '**/fixtures/**' , '**/node_modules/**' ] ,
10
12
interopDefault : false ,
11
13
} ,
14
+ reporters : [ process . env . DEBUG_TESTS ? 'tap' : 'default' ] ,
12
15
coverage : {
13
16
provider : 'c8' ,
14
17
reporter : [ 'text' , 'lcov' ] ,
You can’t perform that action at this time.
0 commit comments