jest-community/jest-extended

'toHaveBeenCalledOnceWith' error message doesn't handle mismatched argument lengths

SLKnutson opened this issue · 1 comments

Bug

  • package version: 3.2.4
  • node version: 18.14.0
  • npm (or yarn) version: 9.4.2

Relevant code or config

  it('bad messaging', () => {
    const obj = {doSomething: (someString, someOtherString) => {}};
    const doSomethingSpy = jest.spyOn(obj, 'doSomething');
    obj.doSomething('hi', 'bye');
    expect(doSomethingSpy).toHaveBeenCalledOnceWith('hi');
  });

Run test. The error message will be

Expected mock function to have been called exactly once with ["hi"], but it was called with:
 "hi"

I would expect it to list the missing expected parameter, like it does for toHaveBeenCalledWith

Expected: "hi"
Received: "hi", "bye"

Thanks!

I think this will be fixed with #572