chai icon indicating copy to clipboard operation
chai copied to clipboard

`calledWithMatch` asserting on reference rather than copy of argument

Open juanatsonhos opened this issue 4 years ago • 1 comments

We have a piece of code which does the following:

async caller_function(param) {
  test_function(param)
  param.property = 'two'
}

caller_function({property: 'one'})

And we want to assert the following:

expect(test_function).to.be.calledWithMatch({
  property: 'one'
})

The issue appears to be that param.property is overwritten by the caller_function, and thus resulting in an assertion error.

juanatsonhos avatar Jun 02 '20 19:06 juanatsonhos