Fix calledWith(objectContaining) when there are multiple calls#15508
Fix calledWith(objectContaining) when there are multiple calls#15508cpojer merged 1 commit intojestjs:mainfrom
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...? |
cpojer
left a comment
There was a problem hiding this comment.
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 thesamplestate 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