@@ -57,6 +57,10 @@ export async function printError(error: unknown, ctx: Vitest, options: PrintErro
5757 printErrorType ( type , ctx )
5858 printErrorMessage ( e , ctx . logger )
5959
60+ // E.g. AssertionError from assert does not set showDiff but has both actual and expected properties
61+ if ( e . diff )
62+ displayDiff ( e . diff , ctx . logger . console )
63+
6064 // if the error provide the frame
6165 if ( e . frame ) {
6266 ctx . logger . error ( c . yellow ( e . frame ) )
@@ -65,7 +69,7 @@ export async function printError(error: unknown, ctx: Vitest, options: PrintErro
6569 printStack ( ctx , stacks , nearest , errorProperties , ( s ) => {
6670 if ( showCodeFrame && s === nearest && nearest ) {
6771 const sourceCode = readFileSync ( nearest . file , 'utf-8' )
68- ctx . logger . error ( c . yellow ( generateCodeFrame ( sourceCode , 4 , s . line , s . column ) ) )
72+ ctx . logger . error ( generateCodeFrame ( sourceCode , 4 , s . line , s . column ) )
6973 }
7074 } )
7175 }
@@ -93,10 +97,6 @@ export async function printError(error: unknown, ctx: Vitest, options: PrintErro
9397 }
9498
9599 handleImportOutsideModuleError ( e . stack || e . stackStr || '' , ctx )
96-
97- // E.g. AssertionError from assert does not set showDiff but has both actual and expected properties
98- if ( e . diff )
99- displayDiff ( e . diff , ctx . logger . console )
100100}
101101
102102function printErrorType ( type : string , ctx : Vitest ) {
@@ -185,7 +185,7 @@ function printModuleWarningForSourceCode(logger: Logger, path: string) {
185185}
186186
187187export function displayDiff ( diff : string , console : Console ) {
188- console . error ( diff )
188+ console . error ( `\n ${ diff } \n` )
189189}
190190
191191function printErrorMessage ( error : ErrorWithDiff , logger : Logger ) {
@@ -203,10 +203,10 @@ function printStack(
203203 const logger = ctx . logger
204204
205205 for ( const frame of stack ) {
206- const color = frame === highlight ? c . yellow : c . gray
206+ const color = frame === highlight ? c . cyan : c . gray
207207 const path = relative ( ctx . config . root , frame . file )
208208
209- logger . error ( color ( ` ${ c . dim ( F_POINTER ) } ${ [ frame . method , c . dim ( `${ path } :${ frame . line } :${ frame . column } ` ) ] . filter ( Boolean ) . join ( ' ' ) } ` ) )
209+ logger . error ( color ( ` ${ c . dim ( F_POINTER ) } ${ [ frame . method , `${ path } :${ c . dim ( ` ${ frame . line } :${ frame . column } `) } ` ] . filter ( Boolean ) . join ( ' ' ) } ` ) )
210210 onStack ?.( frame )
211211 }
212212 if ( stack . length )
0 commit comments