deepEqual doesn't always show an object diff
See original GitHub issueI have seen lots of things like AssertionError: expected [ Array(2) ] to deeply equal [ Array(2) ]
when the objects being compared are very similar and a diff would be useful. I think I have seen chai do this often in the past but not at 3.0.0
.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:12
- Comments:20 (9 by maintainers)
Top Results From Across the Web
object - Javascript - deepEqual Comparison - Stack Overflow
Write a function, deepEqual, that takes two values and returns true only if they are the same value or are objects with the...
Read more >5 Different Ways to Deep Compare JavaScript Objects
Object comparison in JavaScript is not as easy as comparing primitive data types. This article showcases five ways to deep compare JS ...
Read more >Data Structures: Objects and Arrays - Eloquent JavaScript
The binary in operator, when applied to a string and an object, tells you whether that object has a property with that name....
Read more >Node.js v19.3.0 Documentation
deepEqual () will behave like assert.deepStrictEqual() . In strict assertion mode, error messages for objects display a diff. In legacy assertion mode, ...
Read more >How to check two objects have same data using JavaScript
In JavaScript, we cannot directly compare two objects by equality ... above function would fail in case of nested objects as shown below:....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This currently works for me (using Karma as the test runner):
Without it I only see “expected [ Array(1) ] to deeply equal [ Array(1) ]”
Also, I’m going to reiterate this point again:
Chai does not do diffs. If you’re not seeing diffs, then that is an issue with your test runner (e.g. mocha). You should totally file an issue with your test runner about this, here is one for mocha’s html reporter: https://github.com/mochajs/mocha/issues/1348