visionmedia/mocha — pull request #528 by piroor (2012-07-30 07:26:36+00:00)
Title: Output difference between two objects by their stringified versions

When I compare two objects (hashes) for the expected and the actual, then no diff is shown. It is hard to debug if expected and actual values are very large hashes.

For example, with "chai",

assert.deepEqual({ key1: 'value1',
key2: 'value2',
key3: 'value2', // different from below
key4: 'value4',
key5: 'value5' },
{ key1: 'value1',
key2: 'value2',
key3: 'value3',
key4: 'value4',
key5: 'value5' });

Mocha reports an report for the assertion failure like:

1) test:
expected { key1: 'value1',
key2: 'value2',
key3: 'value2',
key4: 'value4',
key5: 'value5' } to deeply equal { key1: 'value1',
key2: 'value2',
key3: 'value3',
key4: 'value4',
key5: 'value5' }

With these patches, Mocha reports the assertion failure like:

![screenshot of colored diff](https://raw.github.com/gist/1357549/9ce0090637871de5fdde0e8d463332c56f4eabfd/deep-equal-with-diff.png)

It is very helpful for debugging.