diff --git a/lib/chai/assertion.js b/lib/chai/assertion.js index b76700c86..e01c6cca8 100644 --- a/lib/chai/assertion.js +++ b/lib/chai/assertion.js @@ -98,7 +98,8 @@ module.exports = function (_chai, util) { Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) { var ok = util.test(this, arguments); - if (true !== showDiff) showDiff = false; + if (false !== showDiff) showDiff = true; + if (undefined === expected && undefined === _actual) showDiff = false; if (true !== config.showDiff) showDiff = false; if (!ok) { diff --git a/test/assert.js b/test/assert.js index 0f62022e9..bc1d93b7f 100644 --- a/test/assert.js +++ b/test/assert.js @@ -865,4 +865,33 @@ describe('assert', function () { }, 'expected {} to not be frozen'); }); }); + + it('showDiff true with actual and expected args', function() { + try { + new chai.Assertion().assert( + 'one' === 'two' + , 'expected #{this} to equal #{exp}' + , 'expected #{this} to not equal #{act}' + , 'one' + , 'two' + ); + } catch(e) { + assert.isTrue(e.showDiff); + } + }); + + it('showDiff false without expected and actual', function() { + try { + new chai.Assertion().assert( + 'one' === 'two' + , 'expected #{this} to equal #{exp}' + , 'expected #{this} to not equal #{act}' + , 'one' + , 'two' + , false + ); + } catch(e) { + assert.isFalse(e.showDiff); + } + }); });