-
-
Notifications
You must be signed in to change notification settings - Fork 699
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
Concerns with deep equality algorithm #907
Comments
@chaijs/chai I've been thinking about this again, somewhat in relation to chaijs/check-error#18 (comment) and #1065. Error objects are going to need some custom logic in the deep equality algorithm to ignore the stack trace. However, I think we should also consider changing how Examples of why: it('test', function () {
function ClassA (val) {
this.val = val;
}
function ClassB (val) {
this.val = val;
}
// Currently passes as expected:
expect(new ClassA('blah')).to.deep.equal(new ClassA('blah'));
// I expect this to pass but it currently fails because prototypes are ignored:
expect(new ClassA('blah')).to.not.deep.equal(new ClassB('blah'));
// I expect this to pass but it currently fails due to the stack trace issue:
expect(new TypeError('blah')).to.deep.equal(new TypeError('blah'));
// I expect this to pass and it currently it does, but if we fix the stack trace issue
// then it'll start to fail unless we compare prototypes:
expect(new TypeError('blah')).to.not.deep.equal(new ReferenceError('blah'));
}); |
I think deep-eql should special case when it "sees" something like
I've added this to our roadmap. So let's track it there. |
We had a discussion in #837 regarding concerns with the deep equality algorithm. We decided to keep the current behavior for now, and perhaps take another look at it post-4.0. I think that's still a good strategy; I'm creating this issue merely for post-4.0 considerations.
Having the deep equality traverse through both own and inherited properties leads to weird situations like this:
Can two objects be considered deep equal if their prototypes aren't deep equal?
The text was updated successfully, but these errors were encountered: