11import type { RunnerTask } from 'vitest/node'
22import { describe , expect , test } from 'vitest'
33import { DefaultReporter } from 'vitest/node'
4- import { runVitest , runVitestCli , StableTestFileOrderSorter } from '#test-utils'
4+ import { runInlineTests , runVitest , runVitestCli , StableTestFileOrderSorter } from '#test-utils'
55import { trimReporterOutput } from './utils'
66
77describe ( 'default reporter' , async ( ) => {
@@ -18,30 +18,38 @@ describe('default reporter', async () => {
1818
1919 expect ( trimReporterOutput ( stdout ) ) . toMatchInlineSnapshot ( `
2020 "❯ b1.test.ts (13 tests | 1 failed) [...]ms
21+ ✓ b1 passed (6)
2122 ✓ b1 test [...]ms
2223 ✓ b2 test [...]ms
2324 ✓ b3 test [...]ms
25+ ✓ nested b (3)
2426 ✓ nested b1 test [...]ms
2527 ✓ nested b2 test [...]ms
2628 ✓ nested b3 test [...]ms
29+ ❯ b1 failed (7)
2730 ✓ b1 test [...]ms
2831 ✓ b2 test [...]ms
2932 ✓ b3 test [...]ms
3033 × b failed test [...]ms
34+ ✓ nested b (3)
3135 ✓ nested b1 test [...]ms
3236 ✓ nested b2 test [...]ms
3337 ✓ nested b3 test [...]ms
3438 ❯ b2.test.ts (13 tests | 1 failed) [...]ms
39+ ✓ b2 passed (6)
3540 ✓ b1 test [...]ms
3641 ✓ b2 test [...]ms
3742 ✓ b3 test [...]ms
43+ ✓ nested b (3)
3844 ✓ nested b1 test [...]ms
3945 ✓ nested b2 test [...]ms
4046 ✓ nested b3 test [...]ms
47+ ❯ b2 failed (7)
4148 ✓ b1 test [...]ms
4249 ✓ b2 test [...]ms
4350 ✓ b3 test [...]ms
4451 × b failed test [...]ms
52+ ✓ nested b (3)
4553 ✓ nested b1 test [...]ms
4654 ✓ nested b2 test [...]ms
4755 ✓ nested b3 test [...]ms"
@@ -66,6 +74,83 @@ describe('default reporter', async () => {
6674 ` )
6775 } )
6876
77+ // https://github.com/vitest-dev/vitest/issues/10606
78+ // With renderSucceed off (non-TTY / multi-file), slow tests and tests with
79+ // inline benchmarks are still logged. Their describe suites must be printed
80+ // above them so the nesting is not lost.
81+ test ( 'prints parent describe suites for slow tests when renderSucceed is off' , async ( ) => {
82+ const { stdout, stderr } = await runInlineTests (
83+ {
84+ 'slow.test.ts' : /* ts */ `
85+ import { describe, test } from 'vitest'
86+
87+ describe('outer', () => {
88+ describe('inner', () => {
89+ test('slow', async () => {
90+ await new Promise(resolve => setTimeout(resolve, 50))
91+ })
92+ })
93+ })
94+ ` ,
95+ } ,
96+ {
97+ reporters : [ [ 'default' , { isTTY : false , summary : false } ] ] ,
98+ slowTestThreshold : 1 ,
99+ } ,
100+ )
101+
102+ expect ( stderr ) . toBe ( '' )
103+ expect ( trimReporterOutput ( stdout ) ) . toMatchInlineSnapshot ( `
104+ "✓ slow.test.ts (1 test) [...]ms
105+ ✓ outer (1)
106+ ✓ inner (1)
107+ ✓ slow [...]ms"
108+ ` )
109+ } )
110+
111+ test ( 'prints parent describe suites for inline benchmarks when renderSucceed is off' , async ( ) => {
112+ const { stdout, stderr } = await runInlineTests (
113+ {
114+ 'suite.bench.ts' : /* ts */ `
115+ import { describe, inject, test } from 'vitest'
116+
117+ describe('my first suite', () => {
118+ test('foo', async ({ bench }) => {
119+ await bench('foo', () => {}).run(inject('options'))
120+ })
121+ })
122+
123+ describe('my second suite', () => {
124+ test('foo', async ({ bench }) => {
125+ await bench('foo', () => {}).run(inject('options'))
126+ })
127+ })
128+ ` ,
129+ } ,
130+ {
131+ benchmark : { enabled : true } ,
132+ reporters : [ [ 'default' , { isTTY : false , summary : false } ] ] ,
133+ provide : { options : { time : 0 , iterations : 1 , warmupTime : 0 , warmupIterations : 0 } } ,
134+ } ,
135+ )
136+
137+ expect ( stderr ) . toBe ( '' )
138+
139+ // benchmark table rows carry runtime-specific numbers, so keep only the
140+ // reporter tree lines when asserting the nesting
141+ const tree = trimReporterOutput ( stdout )
142+ . split ( '\n' )
143+ . filter ( line => / [ ✓ ❯ × ↓ ] / . test ( line ) )
144+ . join ( '\n' )
145+ expect ( tree ) . toMatchInlineSnapshot ( `
146+ "✓ |bench| suite.bench.ts (2 tests) [...]ms
147+ ✓ my first suite (1)
148+ ✓ foo [...]ms
149+ ✓ my second suite (1)
150+ ✓ foo [...]ms"
151+ ` )
152+ } )
153+
69154 test ( 'show full test suite when only one file' , async ( ) => {
70155 const { stdout } = await runVitest ( {
71156 include : [ 'a.test.ts' ] ,
0 commit comments