File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -353,16 +353,18 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
353353 return `${ i } th`
354354 }
355355 const formatCalls = ( spy : EnhancedSpy , msg : string , actualCall ?: any ) => {
356- msg += c ( ) . gray ( `\n\nReceived: \n${ spy . mock . calls . map ( ( callArg , i ) => {
357- let methodCall = c ( ) . bold ( ` ${ ordinalOf ( i + 1 ) } ${ spy . getMockName ( ) } call:\n\n` )
358- if ( actualCall )
359- methodCall += diff ( actualCall , callArg , { showLegend : false } )
360- else
361- methodCall += stringify ( callArg ) . split ( '\n' ) . map ( line => ` ${ line } ` ) . join ( '\n' )
362-
363- methodCall += '\n'
364- return methodCall
365- } ) . join ( '\n' ) } `)
356+ if ( spy . mock . calls ) {
357+ msg += c ( ) . gray ( `\n\nReceived: \n${ spy . mock . calls . map ( ( callArg , i ) => {
358+ let methodCall = c ( ) . bold ( ` ${ ordinalOf ( i + 1 ) } ${ spy . getMockName ( ) } call:\n\n` )
359+ if ( actualCall )
360+ methodCall += diff ( actualCall , callArg , { showLegend : false } )
361+ else
362+ methodCall += stringify ( callArg ) . split ( '\n' ) . map ( line => ` ${ line } ` ) . join ( '\n' )
363+
364+ methodCall += '\n'
365+ return methodCall
366+ } ) . join ( '\n' ) } `)
367+ }
366368 msg += c ( ) . gray ( `\n\nNumber of calls: ${ c ( ) . bold ( spy . mock . calls . length ) } \n` )
367369 return msg
368370 }
You can’t perform that action at this time.
0 commit comments