Skip to content

Commit

Permalink
[WIP] No showDiff on assert interface chaijs#515
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcosta committed Dec 18, 2015
1 parent e1b504c commit ef9a197
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/chai/assertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ 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 (true !== config.showDiff) showDiff = false;
if (false !== showDiff) showDiff = true;
if (undefined === expected && undefined === _actual) showDiff = false;

console.log('expected: ' + expected);
console.log('actual: ' + _actual);
if (!ok) {
var msg = util.getMessage(this, arguments)
, actual = util.getActual(this, arguments);
Expand Down
9 changes: 9 additions & 0 deletions test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,4 +1040,13 @@ describe('assert', function () {
}, 'expected undefined to not be frozen');
});
});

it.only('passing exp and act makes showDiff be true', function() {
try {
assert.equal('one', 'two');
} catch(e) {
console.log(e);
assert.isTrue(e.showDiff);
}
});
});

0 comments on commit ef9a197

Please sign in to comment.