@@ -299,4 +299,101 @@ describe('default reporter', async () => {
299299 } )
300300 expect ( stderr ) . toMatchSnapshot ( )
301301 } )
302+
303+ describe ( 'agent mode' , ( ) => {
304+ test ( 'hides passed module headers and shows only failed tests' , async ( ) => {
305+ const { stdout } = await runVitest ( {
306+ include : [ 'b1.test.ts' , 'b2.test.ts' ] ,
307+ root : 'fixtures/reporters/default' ,
308+ reporters : [ [ 'default' , { isAgent : true } ] ] ,
309+ fileParallelism : false ,
310+ sequence : {
311+ sequencer : StableTestFileOrderSorter ,
312+ } ,
313+ } )
314+
315+ const output = trimReporterOutput ( stdout )
316+ expect ( output ) . toMatchInlineSnapshot ( `
317+ "❯ b1.test.ts (13 tests | 1 failed) [...]ms
318+ × b failed test [...]ms
319+ ❯ b2.test.ts (13 tests | 1 failed) [...]ms
320+ × b failed test [...]ms"
321+ ` )
322+ } )
323+
324+ test ( 'hides all output for passed-only modules' , async ( ) => {
325+ const { stdout } = await runVitest ( {
326+ include : [ 'b1.test.ts' , 'b2.test.ts' ] ,
327+ root : 'fixtures/reporters/default' ,
328+ reporters : [ [ 'default' , { isAgent : true } ] ] ,
329+ fileParallelism : false ,
330+ testNamePattern : 'passed' ,
331+ sequence : {
332+ sequencer : StableTestFileOrderSorter ,
333+ } ,
334+ } )
335+
336+ const output = trimReporterOutput ( stdout )
337+ expect ( output ) . toMatchInlineSnapshot ( `""` )
338+ } )
339+
340+ test ( 'still prints end summary' , async ( ) => {
341+ const { stdout } = await runVitest ( {
342+ include : [ 'b1.test.ts' , 'b2.test.ts' ] ,
343+ root : 'fixtures/reporters/default' ,
344+ reporters : [ [ 'default' , { isAgent : true } ] ] ,
345+ fileParallelism : false ,
346+ sequence : {
347+ sequencer : StableTestFileOrderSorter ,
348+ } ,
349+ } )
350+
351+ expect ( stdout ) . toContain ( 'Test Files' )
352+ expect ( stdout ) . toContain ( 'Tests' )
353+ } )
354+
355+ test ( 'suppresses console logs from passed tests' , async ( ) => {
356+ const { stdout } = await runVitest ( {
357+ config : false ,
358+ include : [ './fixtures/reporters/console-some-failing.test.ts' ] ,
359+ reporters : [ [ 'default' , { isAgent : true , isTTY : true } ] ] ,
360+ } )
361+
362+ expect ( stdout ) . not . toContain ( 'Log from passed test' )
363+ expect ( stdout ) . not . toContain ( 'Log from passed suite' )
364+ } )
365+
366+ test ( 'shows console logs from failed tests' , async ( ) => {
367+ const { stdout } = await runVitest ( {
368+ config : false ,
369+ include : [ './fixtures/reporters/console-some-failing.test.ts' ] ,
370+ reporters : [ [ 'default' , { isAgent : true , isTTY : true } ] ] ,
371+ } )
372+
373+ expect ( stdout ) . toContain ( 'Log from failed test' )
374+ expect ( stdout ) . toContain ( 'Log from failed suite' )
375+ expect ( stdout ) . toContain ( 'Log from failed file' )
376+ } )
377+
378+ test ( 'activates via AI_AGENT env config' , async ( ) => {
379+ const { stdout } = await runVitest ( {
380+ include : [ 'b1.test.ts' , 'b2.test.ts' ] ,
381+ root : 'fixtures/reporters/default' ,
382+ reporters : [ 'default' ] ,
383+ fileParallelism : false ,
384+ env : { AI_AGENT : '1' } ,
385+ sequence : {
386+ sequencer : StableTestFileOrderSorter ,
387+ } ,
388+ } )
389+
390+ const output = trimReporterOutput ( stdout )
391+ expect ( output ) . toMatchInlineSnapshot ( `
392+ "❯ b1.test.ts (13 tests | 1 failed) [...]ms
393+ × b failed test [...]ms
394+ ❯ b2.test.ts (13 tests | 1 failed) [...]ms
395+ × b failed test [...]ms"
396+ ` )
397+ } )
398+ } )
302399} , 120000 )
0 commit comments