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

adding a "retryable fail" event for a test that fails but can be retried #2926

Closed
wants to merge 8 commits into from
2 changes: 2 additions & 0 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ Runner.prototype.runTests = function(suite, fn) {
clonedTest.currentRetry(retry + 1);
tests.unshift(clonedTest);

self.emit('retryable fail', test, err);

// Early return + hook trigger so that it doesn't
// increment the count wrong
return self.hookUp('afterEach', next);
Expand Down
33 changes: 33 additions & 0 deletions test/unit/runner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,39 @@ describe('Runner', function() {
});
});

describe('.run(fn)', function() {
it('should emit "retryable fail" when a retryable test fails', function(done) {
var retries = 2;
var retryableFails = 0;
var ERR = new Error('bear error');

var TEST = new Test('im a test about bears', function() {
if (retryableFails < retries) {
throw ERR;
}
});

suite.retries(retries);
suite.addTest(TEST);

runner.on('retryable fail', function(test, err) {
retryableFails += 1;

// retries clone the tests, so I guess comparing the test
// names should be enough
expect(test.title, 'to be', TEST.title);
expect(err, 'to be', ERR);
});

runner.run(function(failures) {
expect(failures, 'to be', 0);
expect(retryableFails, 'to be', retries);

done();
});
});
});

describe('allowUncaught', function() {
it('should allow unhandled errors to propagate through', function(done) {
var newRunner = new Runner(suite);
Expand Down