-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
False positive behavior toStrictEqual #6759
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
It's not PR welcome if you think the docs can be improved :) |
@rickhanlonii I see you asked OP to open this. Why do you think it's a bug? |
@SimenB more attention pls. I'm talking about array values equality rather than arrays itself. |
Right. Still, your example is supposed to pass, it's not a bug. 2 instances of the same class are considered equal |
@SimenB ok. But is there any way to perform deep/iterable For example to test memoizing. Of course i could use loops like below or create custom matcher, but it will display bad errors. test("", () => {
class HugeFoo {
@memoize
static huge(){}
}
function hugeTask() {
return [10, HugeFoo.huge()]
}
const a1 = hugeTask();
const a2 = hugeTask();
expect(a1).toEqual(a2);
expect(a1).toStrictEqual(a2);
expect(a1.length).toBe(a2.length);
for (let i = 0; i < a1.length; i++) {
expect(a1[i]).toBe(a2[i]);
}
}); |
@mattphillips are there any matchers for this in jest-extended? |
Ah, my mistake |
@rickhanlonii nevertheless bug exists when comparing 2 instances of different classes with identical name. |
@rickhanlonii @SimenB |
@SimenB
const object = Object(1);
expect(object).toStrictEqual(1);
// pass, but should not - they have different types.
// typeof object !== typeof 1 expect(new Number(1)).toStrictEqual(new Number(2));
// fail, but they have same structure, and same type |
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
.toStrictEqual
doesn't perform===
equality check for nested objectsTo Reproduce
Expected behavior
expect([p1]).toStrictEqual([p2])
should not passThe text was updated successfully, but these errors were encountered: