-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Fix calledWith(objectContaining) when there are multiple calls #15508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
bc00fc9
to
6375e33
Compare
This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Still waiting for review...? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. We should absolutely never mutate user data.
I didn't verify, but I believe this also fixes #15442 |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
#15038 introduced an issue (#15501) where
expect(fn).toHaveBeenCalledWith(expect.objectContaining(...))
would not work if the function was called multiple times, due to mutation of thesample
state after each non-matching call.This PR reverts the change and adds tests which will catch the issue if it's re-introduced.
Initially I thought I'd found a way to fix the issue and preserve the formatting improvements, but while adding tests, I found some cases where the failure messages were misleading (extra "expected" object properties shown that weren't originally present--example). I couldn't think of a way to fix that case without adding a new option to
pretty-format
, so it seemed best to just revert the change since correctness is more important than improved formatting.Test plan
Existing tests pass (one snapshot changed due to the revert). Added tests which would detect if this issue is re-introduced.
Fixes #15501