mochajs/mocha — pull request #1477 by marcello3d (2014-12-21 04:12:04+00:00)
Title: showDiff: don’t stringify strings + tests

The showDiff feature is stringifying strings as JSON, which flattens multi-line text with \n and surrounds them with quotes.

I refactored the code slightly to only call `utils.stringify` if the actual/expected values are *not* strings.

You can see the bug by running mocha on the following .js file:
```js
var test = require('mocha').it
var assert = require('assert')

assert.AssertionError.prototype.showDiff = true

test('compare multiline strings', function(){
assert.equal("foo\ncar", "foo\nbar");
});
```
Current (mocha 2.0.1) output:
```
1) compare multiline strings:

AssertionError: "foo\ncar" == "foo\nbar"
+ expected - actual

+"foo\nbar"
-"foo\ncar"
```
After patch:
```
1) compare multiline strings:

AssertionError: "foo\ncar" == "foo\nbar"
+ expected - actual

foo
+bar
-car
```