@@ -397,7 +397,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
397
397
const callCount = spy . mock . calls . length
398
398
return this . assert (
399
399
callCount === number ,
400
- `expected "${ spyName } " to be called #{exp} times` ,
400
+ `expected "${ spyName } " to be called #{exp} times, but got ${ callCount } times ` ,
401
401
`expected "${ spyName } " to not be called #{exp} times` ,
402
402
number ,
403
403
callCount ,
@@ -410,7 +410,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
410
410
const callCount = spy . mock . calls . length
411
411
return this . assert (
412
412
callCount === 1 ,
413
- `expected "${ spyName } " to be called once` ,
413
+ `expected "${ spyName } " to be called once, but got ${ callCount } times ` ,
414
414
`expected "${ spyName } " to not be called once` ,
415
415
1 ,
416
416
callCount ,
@@ -420,14 +420,15 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
420
420
def ( [ 'toHaveBeenCalled' , 'toBeCalled' ] , function ( ) {
421
421
const spy = getSpy ( this )
422
422
const spyName = spy . getMockName ( )
423
- const called = spy . mock . calls . length > 0
423
+ const callCount = spy . mock . calls . length
424
+ const called = callCount > 0
424
425
const isNot = utils . flag ( this , 'negate' ) as boolean
425
426
let msg = utils . getMessage (
426
427
this ,
427
428
[
428
429
called ,
429
430
`expected "${ spyName } " to be called at least once` ,
430
- `expected "${ spyName } " to not be called at all` ,
431
+ `expected "${ spyName } " to not be called at all, but actually been called ${ callCount } times ` ,
431
432
true ,
432
433
called ,
433
434
] ,
0 commit comments