-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
Provide friendly error message when deep equality check fails because object has property value of undefined #304
Comments
Thanks @OliverJAsh for the issue. Seems like it is semi related to your issue over in #246? I'd like to see more discussion on this one before prompting for a PR. Maybe @logicalparadox or @vesln have some thoughts? |
I have easily lost hours debugging the difference between two objects that appear identical (for some reason Mocha also hangs in this case so it's hard to tell which test is even failing). It would be great if this discrepancy is somehow indicated. Is there a significant semantic difference between an object with a property holding an undefined value, and an object without that property? |
Thanks for your comments @ahamid, and bringing light to this (quite old) issue. A couple of points on this:
If we can get Loupe doing more interesting inspection, by passing it comparison objects, then this would solve this problem without relying on the test runner's diff output, and provide much better error messages. If anyone wants to take a stab at this I'm happy to work with/mentor them. It'd be reasonably complex, probably involve quite a bit of logic (effectively a diffing algo) but it'd be a huge improvement to error messages 😄 |
Hey @ahamid thanks for bringing this to my attention again. This issue has been raised a few times. I've raised an issue within the loupe project that is similar to this one (chaijs/loupe#1) and better describes the problem. This is also kind of a dupe of #469 so I'm going to close this one. I'm closing this issue in favour of chaijs/loupe#1 - which will really help us out in part, but also one of things problematic to us is that Mocha's diffing is not the best it could be. mochajs/mocha#1348 exists as part of this, but more investment needs to be made here. |
That's not helpful. This can be fixed by setting
chai.config.truncateThreshold = 0;
.Would it be better if we showed a diff to the user? This way, the error is clear to the user immediately (no Chai config required):
The text was updated successfully, but these errors were encountered: