diff --git a/lib/reporters/base.js b/lib/reporters/base.js index 24072ebb43..1a584555ee 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -161,8 +161,10 @@ exports.list = function(failures){ , expected = err.expected , escape = true; - // explicitly show diff - if (err.showDiff) { + // explicitly show diff for non-string values + // no need to call JSON.stringify on strings and escape should be true if + // value is a string, otherwise multi-line diffs won't work properly + if (err.showDiff && ('string' != typeof actual || 'string' != typeof expected)) { escape = false; err.actual = actual = JSON.stringify(actual, null, 2); err.expected = expected = JSON.stringify(expected, null, 2); diff --git a/test/acceptance/diffs.js b/test/acceptance/diffs.js index 297a1f1f71..5d13ab9517 100644 --- a/test/acceptance/diffs.js +++ b/test/acceptance/diffs.js @@ -19,6 +19,12 @@ describe('diffs', function(){ }) it('should display a word diff for large strings', function(){ - // cssin.should.equal(cssout); + var err = new Error(); + err.message = 'strings are not the same'; + err.expected = cssout; + err.actual = cssin; + // showDiff = true to check conflicts with multi-line string diffs + err.showDiff = true; + // throw err; }) -}) \ No newline at end of file +})