-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
toHaveBeenCalledWith
objectContaining
issue after patch update 26.6.1
#10716
Comments
Would the solution here be something along the lines of only recursively check objects and arrays that are vanilla objects/arrays? I'm not 100% sure on the best way to even do that, this is what I came up with: const expected =
typeof this.sample[property] === 'object' &&
(
Object.getPrototypeOf(this.sample[property]) === Object.prototype ||
Object.getPrototypeOf(this.sample[property]) === Array.prototype
)
? objectContaining(this.sample[property] as Record<string, unknown>)
: this.sample[property]; |
If that passes the tests I'm happy 🙂 Send a PR? If it doesn't work we might have to revert #10508 |
Repost from #10720:
and we'd be re-using existing battle-proven code for this... |
Experiencing the same error. Apparently our test didn't even need |
That's complicated. As far as I can tell: 1) no, that's not equivalent; 2) yes, that passes all existing tests, more or less (implying that a large number of cases are not covered by current tests); and 3) I think that does solve this issue's particular bug, so if they were equivalent, reimplementing in terms of One difference between Similar differences should arise (though I have not tested this) wherever These differences existed prior to #10508 (probably since the original implementation of Another difference is that There may be other differences that I didn't catch. On master, reimplementing in terms of Also passes the cross-realm input test from ninevra@0553005 (though that's hardly exhaustive). It fails @scagood's tests for recursing into |
TBH, and I've said this to @SimenB a couple of days ago, I think we should revert #10508 and change the documentation instead. It was merged without discussion and to implement it properly would require something as complex as our subset equality check, except different in a variety of ways. I think it's totally reasonable for |
Yeah, I'm leaning towards reverting and perhaps updating the docs to be explicit about depth |
Will revert tomorrow (Monday), /cc @ioancole |
Revert released in https://github.com/facebook/jest/releases/tag/v26.6.2 |
I spend literally a day trying to figure out why my tests failing. At the end of the day I found strange behaviour in other places was caused by
I checked out the latest changes in Jest and Voila! Someone has fixed it today in |
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. |
🐛 Bug Report
Tests that contain Buffers in
expect.objectContaining
calls started failing after a patch version update.To Reproduce
A private repo received a dependabot PR for the following update:
Bump jest from 26.6.0 to 26.6.1
Previously this test would have passed:
That test now throws:
Expected behavior
Tests to not start failing after a patch update 😅
envinfo
Before:
After:
The text was updated successfully, but these errors were encountered: