diff --git a/bin/mocha.js b/bin/mocha.js old mode 100644 new mode 100755 diff --git a/lib/reporters/spec.js b/lib/reporters/spec.js index 8497249f73..5c56694db6 100644 --- a/lib/reporters/spec.js +++ b/lib/reporters/spec.js @@ -67,20 +67,34 @@ function Spec(runner, options) { }); runner.on(EVENT_TEST_PASS, function (test) { + function logRetries() { + if (test._currentRetry > 0) { + /* + Included message within format so it can be passed into `Base.consoleLog` as one argument + */ + var retryFmt = color( + 'bright yellow', + ` (retry x${test._currentRetry})` + ); + return retryFmt; + } else { + return ''; + } + } var fmt; if (test.speed === 'fast') { fmt = indent() + color('checkmark', ' ' + Base.symbols.ok) + color('pass', ' %s'); - Base.consoleLog(fmt, test.title); + Base.consoleLog(fmt, test.title, logRetries()); } else { fmt = indent() + color('checkmark', ' ' + Base.symbols.ok) + color('pass', ' %s') + color(test.speed, ' (%dms)'); - Base.consoleLog(fmt, test.title, test.duration); + Base.consoleLog(fmt, test.title, test.duration, logRetries()); } }); diff --git a/test/integration/retries.spec.js b/test/integration/retries.spec.js index a9cb46a42c..496f3b9db9 100644 --- a/test/integration/retries.spec.js +++ b/test/integration/retries.spec.js @@ -134,4 +134,37 @@ describe('retries', function () { } ); }); + + it('should return current retry count out of total retry count', function (done) { + helpers.runMocha( + 'retries/early-pass.fixture.js', + ['--reporter', 'spec'], + function (err, res) { + var lines, expected; + + if (err) { + done(err); + return; + } + + lines = res.output + .split(helpers.SPLIT_DOT_REPORTER_REGEXP) + .map(function (line) { + return line.trim(); + }) + .filter(function (line) { + return line.length; + }) + .slice(0, -1); + + var retryPattern = /\(retry x\d+\)/; + + var actual = lines[1].match(retryPattern)[0]; + var expected = '(retry x1)'; + + assert.equal(actual, expected); + done(); + } + ); + }); }); diff --git a/test/reporters/spec.spec.js b/test/reporters/spec.spec.js index 39115ffa35..ebd6ce08b3 100644 --- a/test/reporters/spec.spec.js +++ b/test/reporters/spec.spec.js @@ -101,7 +101,7 @@ describe('Spec reporter', function () { ' (' + expectedDuration + 'ms)' + - '\n'; + ' \n'; expect(stdout[0], 'to be', expectedString); }); }); @@ -128,7 +128,7 @@ describe('Spec reporter', function () { sinon.restore(); var expectedString = - ' ' + Base.symbols.ok + ' ' + expectedTitle + '\n'; + ' ' + Base.symbols.ok + ' ' + expectedTitle + ' \n'; expect(stdout[0], 'to be', expectedString); }); });