question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

deepEqual doesn't always show an object diff

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Reactions:12
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

47reactions
fabiosussettocommented, Oct 19, 2015

This currently works for me (using Karma as the test runner):

chai.config.truncateThreshold = 0

Without it I only see “expected [ Array(1) ] to deeply equal [ Array(1) ]”

7reactions
keithamuscommented, Nov 4, 2015

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found