From ecefec83c60128d21197b4c70a5602d0cd2ef858 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Mon, 11 Dec 2017 22:40:13 -0800 Subject: [PATCH] fixup no-diff tests to use expect.js for #2536 --- lib/reporters/base.js | 5 +---- test/integration/no-diff.spec.js | 30 +++++++++++++++++++++++++----- test/reporters/base.spec.js | 4 ++-- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/lib/reporters/base.js b/lib/reporters/base.js index 94339f346d..d5425c8a53 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -208,11 +208,8 @@ exports.list = function (failures) { if (err.uncaught) { msg = 'Uncaught ' + msg; } - // explicitly show diff - if (exports.hideDiff !== true && err.showDiff !== false && sameType(actual, expected) && expected !== undefined) { - escape = false; - if (showDiff(err)) { + if (!exports.hideDiff && showDiff(err)) { stringifyDiffObjs(err); fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n'); var match = message.match(/^([^:]+): expected/); diff --git a/test/integration/no-diff.spec.js b/test/integration/no-diff.spec.js index 5766abce51..10bb53c2d7 100644 --- a/test/integration/no-diff.spec.js +++ b/test/integration/no-diff.spec.js @@ -4,11 +4,31 @@ var helpers = require('./helpers'); var run = helpers.runMocha; describe('no-diff', function () { - it('should be honoured', function (done) { - run('no-diff.fixture.js', ['--no-diff'], function (err, res) { - res.output.should.not.match(/\+ expected/); - res.output.should.not.match(/- actual/); - done(err); + describe('when enabled', function () { + it('should not display a diff', function (done) { + run('no-diff.fixture.js', ['--no-diff'], function (err, res) { + if (err) { + done(err); + return; + } + expect(res.output).not.to.match(/\+ expected/); + expect(res.output).not.to.match(/- actual/); + done(); + }); + }); + }); + + describe('when disabled', function () { + it('should display a diff', function (done) { + run('no-diff.fixture.js', ['--diff'], function (err, res) { + if (err) { + done(err); + return; + } + expect(res.output).to.match(/\+ expected/); + expect(res.output).to.match(/- actual/); + done(); + }); }); }); }); diff --git a/test/reporters/base.spec.js b/test/reporters/base.spec.js index e9118186a7..087aa74f6e 100644 --- a/test/reporters/base.spec.js +++ b/test/reporters/base.spec.js @@ -108,8 +108,8 @@ describe('Base reporter', function () { Base.hideDiff = false; // Revert to original value errOut = stdout.join('\n'); - errOut.should.not.match(/\- actual/); - errOut.should.not.match(/\+ expected/); + expect(errOut).to.not.match(/- actual/); + expect(errOut).to.not.match(/\+ expected/); }); });