@@ -58,6 +58,22 @@ test('correctly outputs json', async () => {
58
58
expect ( exitCode ) . toBe ( 0 )
59
59
} )
60
60
61
+ test ( 'correctly outputs files only json' , async ( ) => {
62
+ const { stdout, exitCode } = await runVitestCli ( 'list' , '-r=./fixtures/list' , '--json' , '--filesOnly' )
63
+ expect ( relative ( stdout ) ) . toMatchInlineSnapshot ( `
64
+ "[
65
+ {
66
+ "file": "<root>/fixtures/list/basic.test.ts"
67
+ },
68
+ {
69
+ "file": "<root>/fixtures/list/math.test.ts"
70
+ }
71
+ ]
72
+ "
73
+ ` )
74
+ expect ( exitCode ) . toBe ( 0 )
75
+ } )
76
+
61
77
test ( 'correctly saves json' , async ( ) => {
62
78
const { stdout, exitCode } = await runVitestCli ( 'list' , '-r=./fixtures/list' , '--json=./list.json' )
63
79
onTestFinished ( ( ) => {
@@ -96,6 +112,26 @@ test('correctly saves json', async () => {
96
112
expect ( exitCode ) . toBe ( 0 )
97
113
} )
98
114
115
+ test ( 'correctly saves files only json' , async ( ) => {
116
+ const { stdout, exitCode } = await runVitestCli ( 'list' , '-r=./fixtures/list' , '--json=./list.json' , '--filesOnly' )
117
+ onTestFinished ( ( ) => {
118
+ rmSync ( './fixtures/list/list.json' )
119
+ } )
120
+ const json = readFileSync ( './fixtures/list/list.json' , 'utf-8' )
121
+ expect ( stdout ) . toBe ( '' )
122
+ expect ( relative ( json ) ) . toMatchInlineSnapshot ( `
123
+ "[
124
+ {
125
+ "file": "<root>/fixtures/list/basic.test.ts"
126
+ },
127
+ {
128
+ "file": "<root>/fixtures/list/math.test.ts"
129
+ }
130
+ ]"
131
+ ` )
132
+ expect ( exitCode ) . toBe ( 0 )
133
+ } )
134
+
99
135
test ( 'correctly filters by file' , async ( ) => {
100
136
const { stdout, exitCode } = await runVitestCli ( 'list' , 'math.test.ts' , '-r=./fixtures/list' )
101
137
expect ( stdout ) . toMatchInlineSnapshot ( `
@@ -106,6 +142,15 @@ test('correctly filters by file', async () => {
106
142
expect ( exitCode ) . toBe ( 0 )
107
143
} )
108
144
145
+ test ( 'correctly filters by file when using --filesOnly' , async ( ) => {
146
+ const { stdout, exitCode } = await runVitestCli ( 'list' , 'math.test.ts' , '-r=./fixtures/list' , '--filesOnly' )
147
+ expect ( stdout ) . toMatchInlineSnapshot ( `
148
+ "math.test.ts
149
+ "
150
+ ` )
151
+ expect ( exitCode ) . toBe ( 0 )
152
+ } )
153
+
109
154
test ( 'correctly prints project name in basic report' , async ( ) => {
110
155
const { stdout } = await runVitestCli ( 'list' , 'math.test.ts' , '-r=./fixtures/list' , '--config=./custom.config.ts' )
111
156
expect ( stdout ) . toMatchInlineSnapshot ( `
@@ -115,6 +160,14 @@ test('correctly prints project name in basic report', async () => {
115
160
` )
116
161
} )
117
162
163
+ test ( 'correctly prints project name in basic report when using --filesOnly' , async ( ) => {
164
+ const { stdout } = await runVitestCli ( 'list' , 'math.test.ts' , '-r=./fixtures/list' , '--config=./custom.config.ts' , '--filesOnly' )
165
+ expect ( stdout ) . toMatchInlineSnapshot ( `
166
+ "[custom] math.test.ts
167
+ "
168
+ ` )
169
+ } )
170
+
118
171
test ( 'correctly prints project name and locations in json report' , async ( ) => {
119
172
const { stdout } = await runVitestCli ( 'list' , 'math.test.ts' , '-r=./fixtures/list' , '--json' , '--config=./custom.config.ts' )
120
173
expect ( relative ( stdout ) ) . toMatchInlineSnapshot ( `
@@ -142,6 +195,19 @@ test('correctly prints project name and locations in json report', async () => {
142
195
` )
143
196
} )
144
197
198
+ test ( 'correctly prints project name in json report when using --filesOnly' , async ( ) => {
199
+ const { stdout } = await runVitestCli ( 'list' , 'math.test.ts' , '-r=./fixtures/list' , '--json' , '--config=./custom.config.ts' , '--filesOnly' )
200
+ expect ( relative ( stdout ) ) . toMatchInlineSnapshot ( `
201
+ "[
202
+ {
203
+ "file": "<root>/fixtures/list/math.test.ts",
204
+ "projectName": "custom"
205
+ }
206
+ ]
207
+ "
208
+ ` )
209
+ } )
210
+
145
211
test ( 'correctly filters by test name' , async ( ) => {
146
212
const { stdout } = await runVitestCli ( 'list' , '-t=inner' , '-r=./fixtures/list' )
147
213
expect ( stdout ) . toMatchInlineSnapshot ( `
0 commit comments