Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec-reporter prints retries #5099

Closed
Empty file modified bin/mocha.js
100644 → 100755
CheadleCheadle marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
15 changes: 15 additions & 0 deletions lib/reporters/spec.js
CheadleCheadle marked this conversation as resolved.
Show resolved Hide resolved
CheadleCheadle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,35 @@ function Spec(runner, options) {
});

runner.on(EVENT_TEST_PASS, function (test) {
function logRetries() {
if (test._retries > 0) {
CheadleCheadle marked this conversation as resolved.
Show resolved Hide resolved
var retryFmt = indent() + color('bright yellow', ' %s');
var retryMessage =
test._currentRetry > 0
? `(Succeeded after ${test._currentRetry} / ${test._retries} retries)`
: '';

if (retryMessage) {
Base.consoleLog(retryFmt, retryMessage);
}
}
}
var fmt;
if (test.speed === 'fast') {
fmt =
indent() +
color('checkmark', ' ' + Base.symbols.ok) +
color('pass', ' %s');
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);
logRetries();
}
CheadleCheadle marked this conversation as resolved.
Show resolved Hide resolved
});

Expand Down
30 changes: 30 additions & 0 deletions test/integration/retries.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,34 @@ 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 expected = '(Succeeded after 1 / 1 retries)';

assert.equal(lines[2], expected);
done();
}
);
});
});
Loading