@@ -10,7 +10,7 @@ import type { Vitest } from '../core'
10
10
import type { Reporter } from '../types/reporter'
11
11
import type { ErrorWithDiff , UserConsoleLog } from '../../types/general'
12
12
import { hasFailedSnapshot } from '../../utils/tasks'
13
- import { F_POINTER , F_RIGHT } from './renderers/figures'
13
+ import { F_CHECK , F_POINTER , F_RIGHT } from './renderers/figures'
14
14
import {
15
15
countTestErrors ,
16
16
divider ,
@@ -131,13 +131,7 @@ export abstract class BaseReporter implements Reporter {
131
131
state += ` ${ c . dim ( '|' ) } ${ c . yellow ( `${ skipped . length } skipped` ) } `
132
132
}
133
133
let suffix = c . dim ( ' (' ) + state + c . dim ( ')' )
134
- if ( task . result . duration ) {
135
- const color
136
- = task . result . duration > this . ctx . config . slowTestThreshold
137
- ? c . yellow
138
- : c . gray
139
- suffix += color ( ` ${ Math . round ( task . result . duration ) } ${ c . dim ( 'ms' ) } ` )
140
- }
134
+ suffix += this . getDurationPrefix ( task )
141
135
if ( this . ctx . config . logHeapUsage && task . result . heap != null ) {
142
136
suffix += c . magenta (
143
137
` ${ Math . floor ( task . result . heap / 1024 / 1024 ) } MB heap used` ,
@@ -154,13 +148,36 @@ export abstract class BaseReporter implements Reporter {
154
148
title += `${ task . name } ${ suffix } `
155
149
logger . log ( title )
156
150
157
- // print short errors, full errors will be at the end in summary
158
- for ( const test of failed ) {
159
- logger . log ( c . red ( ` ${ taskFail } ${ getTestName ( test , c . dim ( ' > ' ) ) } ` ) )
160
- test . result ?. errors ?. forEach ( ( e ) => {
161
- logger . log ( c . red ( ` ${ F_RIGHT } ${ ( e as any ) ?. message } ` ) )
162
- } )
151
+ for ( const test of tests ) {
152
+ const duration = test . result ?. duration
153
+ if ( test . result ?. state === 'fail' ) {
154
+ const suffix = this . getDurationPrefix ( test )
155
+ logger . log ( c . red ( ` ${ taskFail } ${ getTestName ( test , c . dim ( ' > ' ) ) } ${ suffix } ` ) )
156
+
157
+ test . result ?. errors ?. forEach ( ( e ) => {
158
+ // print short errors, full errors will be at the end in summary
159
+ logger . log ( c . red ( ` ${ F_RIGHT } ${ ( e as any ) ?. message } ` ) )
160
+ } )
161
+ }
162
+ // also print slow tests
163
+ else if ( duration && duration > this . ctx . config . slowTestThreshold ) {
164
+ logger . log (
165
+ ` ${ c . yellow ( c . dim ( F_CHECK ) ) } ${ getTestName ( test , c . dim ( ' > ' ) ) } ${ c . yellow (
166
+ ` ${ Math . round ( duration ) } ${ c . dim ( 'ms' ) } ` ,
167
+ ) } `,
168
+ )
169
+ }
170
+ }
171
+ }
172
+
173
+ private getDurationPrefix ( task : Task ) {
174
+ if ( ! task . result ?. duration ) {
175
+ return ''
163
176
}
177
+ const color = task . result . duration > this . ctx . config . slowTestThreshold
178
+ ? c . yellow
179
+ : c . gray
180
+ return color ( ` ${ Math . round ( task . result . duration ) } ${ c . dim ( 'ms' ) } ` )
164
181
}
165
182
166
183
onWatcherStart (
0 commit comments