-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Ambigious comparing primitive with object #6784
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
Comments
Another great example: test("", () => {
const obj = new Boolean(false);
const proxy = new Proxy(obj, {});
expect(false).toEqual(obj); // pass
expect(false).toStrictEqual(obj); // pass
expect(false).toEqual(proxy); // fail
expect(false).toStrictEqual(proxy); // fail
}); |
not sure if this is a bug or expected behaviour? @thymikee @rickhanlonii thoughts? |
Also not sure, I'd need to check the spec to see if all this makes sense 🤷♂️ |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
🐛 Bug Report
Primitive values compare with objects is ambigious
Look at example. there are 4 test cases
Boolean
- native Boolean constructorBoolean
extending native BooleanBoolean2
extending native BooleanBoolean
At all iterations
true
compared with some object (more over - I explicitly setexpected.x = 1
)Results
Expected behavior
All of these test should fall because
true
not equalobject with x = 1
(at leasttoStrictEqual
)The text was updated successfully, but these errors were encountered: