Skip to content

BUG: toHaveBeenCalledExactlyOnceWith only reports first argument of method call in feedback on a failed assertion. #690

Open
@GRollason

Description

@GRollason

Bug

  • package version: 4.0.2
  • node version: 20.12.0
  • npm (or yarn) version: 10.5.0

Relevant code or config

Test code: expect(methodName).toHaveBeenCalledExactlyOnceWith(1stArgument)
Implementation code: methodName(1stArgument, 2ndArgument)

What you did:
Asserted 'toHaveBeenCalledExactlyOnceWith' with an incorrect number of arguments.

What happened (please provide anything you think will help):
The error message states:
'Expected mock function to have been called exactly once with [1stArgument], but it was called with [1stArgument]'
The output should presumably be 'Expected mock function to have been called exactly once with [1stArgument], but it was called with [1stArgument, 2ndArgument]'.

First argument in question was an object, the second was a primitive Boolean. This is obviously quite painful as the output from the failed assertion looks to be correct, despite the reported error.

Reproduction repository (if possible):
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions