@@ -58,6 +58,22 @@ test('correctly outputs json', async () => {
5858 expect ( exitCode ) . toBe ( 0 )
5959} )
6060
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+
6177test ( 'correctly saves json' , async ( ) => {
6278 const { stdout, exitCode } = await runVitestCli ( 'list' , '-r=./fixtures/list' , '--json=./list.json' )
6379 onTestFinished ( ( ) => {
@@ -96,6 +112,26 @@ test('correctly saves json', async () => {
96112 expect ( exitCode ) . toBe ( 0 )
97113} )
98114
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+
99135test ( 'correctly filters by file' , async ( ) => {
100136 const { stdout, exitCode } = await runVitestCli ( 'list' , 'math.test.ts' , '-r=./fixtures/list' )
101137 expect ( stdout ) . toMatchInlineSnapshot ( `
@@ -106,6 +142,15 @@ test('correctly filters by file', async () => {
106142 expect ( exitCode ) . toBe ( 0 )
107143} )
108144
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+
109154test ( 'correctly prints project name in basic report' , async ( ) => {
110155 const { stdout } = await runVitestCli ( 'list' , 'math.test.ts' , '-r=./fixtures/list' , '--config=./custom.config.ts' )
111156 expect ( stdout ) . toMatchInlineSnapshot ( `
@@ -115,6 +160,14 @@ test('correctly prints project name in basic report', async () => {
115160 ` )
116161} )
117162
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+
118171test ( 'correctly prints project name and locations in json report' , async ( ) => {
119172 const { stdout } = await runVitestCli ( 'list' , 'math.test.ts' , '-r=./fixtures/list' , '--json' , '--config=./custom.config.ts' )
120173 expect ( relative ( stdout ) ) . toMatchInlineSnapshot ( `
@@ -142,6 +195,19 @@ test('correctly prints project name and locations in json report', async () => {
142195 ` )
143196} )
144197
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+
145211test ( 'correctly filters by test name' , async ( ) => {
146212 const { stdout } = await runVitestCli ( 'list' , '-t=inner' , '-r=./fixtures/list' )
147213 expect ( stdout ) . toMatchInlineSnapshot ( `
0 commit comments