-
-
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
Circular reference object equality is not symmetrical #7555
Comments
I can take this one :) thanks for a very clear description |
I've been quite busy for past month, so only now I managed to get back to the issue. Above case breaks in every popular library(underscore, lodash, ramda). Since Jest's equality is based on underscore's implementation, it has the same problem. Only node.js equality is consistent with this case. ramda returns true for this case but if you add one level of nesting, it returns false. You can check out an example here. We can solve the issue this way, by adding another check
This is a very primitive solution, but it works. I tried some other options, but this seemed the most reasonable to implement for now. One of them was to copy Node's @SimenB could you please give your opinion on the issue? |
Wow this is an interesting one :D |
I don't really have an opinion on a solution, beyond agreeing it's a bug. I'm not sure if the bug is |
I see.
if you open circular, the depth of I will probably open the issues in other libraries and hopefully will get some ideas :) |
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
Circular structure comparison is wrong.
The algorithm for determining object equality is asymmetric and causes problems. Pretty sure that the following lines create the problem:
https://github.com/facebook/jest/blob/fe19d6978858d76e1cb7544b39a56250a18b2103/packages/expect/src/jasmineUtils.js#L150-L157
To Reproduce
Expected behavior
Both tests should pass or both tests should fail - design decision
Link to repl or repo (highly encouraged)
https://repl.it/repls/VagueRashBraces
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: