You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expect(mock).toBeCalledWith(...) function doesn't compare objects with the state when it was called. It seems to be holding the reference to the object, so when the mock function was called with an object reference to { a: 'foo' } and the object was updated afterwards, expect(mock).toBeCalledWith(...) compares with the latest state of the object, not { a: 'foo' }.
To Reproduce
Steps to reproduce the behavior:
Implementation with update obj after the fn function was called, so it should be called with { a: 'foo' }
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
馃悰 Bug Report
expect(mock).toBeCalledWith(...)
function doesn't compare objects with the state when it was called. It seems to be holding the reference to the object, so when the mock function was called with an object reference to{ a: 'foo' }
and the object was updated afterwards,expect(mock).toBeCalledWith(...)
compares with the latest state of the object, not{ a: 'foo' }
.To Reproduce
Steps to reproduce the behavior:
Implementation with update
obj
after thefn
function was called, so it should be called with{ a: 'foo' }
and, in the test, pass
jest.fn()
to the fucntion (objectUpdate
)which fails with:
Expected behavior
The test above should pass because when the
fn
function is called, theobj
is just{ a: 'foo' }
.Link to repl or repo (highly encouraged)
https://replit.com/@mikamikuh/jest-playground#object-update.js
envinfo
The text was updated successfully, but these errors were encountered: