@@ -10,7 +10,7 @@ import type { Vitest } from '../core'
1010import type { Reporter } from '../types/reporter'
1111import type { ErrorWithDiff , UserConsoleLog } from '../../types/general'
1212import { hasFailedSnapshot } from '../../utils/tasks'
13- import { F_POINTER , F_RIGHT } from './renderers/figures'
13+ import { F_CHECK , F_POINTER , F_RIGHT } from './renderers/figures'
1414import {
1515 countTestErrors ,
1616 divider ,
@@ -131,13 +131,7 @@ export abstract class BaseReporter implements Reporter {
131131 state += ` ${ c . dim ( '|' ) } ${ c . yellow ( `${ skipped . length } skipped` ) } `
132132 }
133133 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 )
141135 if ( this . ctx . config . logHeapUsage && task . result . heap != null ) {
142136 suffix += c . magenta (
143137 ` ${ Math . floor ( task . result . heap / 1024 / 1024 ) } MB heap used` ,
@@ -154,13 +148,36 @@ export abstract class BaseReporter implements Reporter {
154148 title += `${ task . name } ${ suffix } `
155149 logger . log ( title )
156150
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 ''
163176 }
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' ) } ` )
164181 }
165182
166183 onWatcherStart (
0 commit comments