-
-
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
toEqual
does not treat non-enumerable properties equally
#6392
Comments
mweststrate
added a commit
to mobxjs/mobx
that referenced
this issue
Jun 4, 2018
Skip until jestjs/jest#6392 is resolved
mweststrate
added a commit
to mweststrate/jest
that referenced
this issue
Jun 5, 2018
Added PR: #6398, as that is often more clarifying than a bug report :) |
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
🐛 Bug Report
I discovered some inconsistent behavior in the
toEqual
matcher in Jest; when comparing to objects, it ignores non-enumerable properties, but only if they are not symbols. This leads to quite inconsistent behavior:This test passes:
But this one doesn't:
Where one would expect both to behave the same.
The cause of the issue can be found here. To find the string properties the
for..in
loop is used which ignores non-enumerable properties, but for the symbolic properties getOwnPropertySymbols is used, which will include non-enumerable properties.To Reproduce
See link below
Expected behavior
Non-enumerable symbolic properties should be treated the same as non-enumerable non-symbolic properties when running
toEqual
. Either both should be included, or excluded. Given that symbolic properties are lot more exotic, I think the behavior of string properties should be followed and non-enumerable symbolic properties should be excluded from deep equality.I am willing to file a PR myself
Link to repl or repo (highly encouraged)
https://repl.it/@mweststrate/IckyMeanProgrammers
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: