Skip to content

Commit

Permalink
runner.js: this.skip() in beforeEach hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jul 23, 2019
1 parent 1e6cf3b commit db56f38
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/runner.js
Expand Up @@ -394,10 +394,16 @@ Runner.prototype.hook = function(name, fn) {
'Use a return statement or other means to abort hook execution.'
);
}
if (name === HOOK_TYPE_BEFORE_EACH || name === HOOK_TYPE_AFTER_EACH) {
if (name === HOOK_TYPE_AFTER_EACH) {
if (self.test) {
self.test.pending = true;
}
} else if (name === HOOK_TYPE_BEFORE_EACH) {
if (self.test) {
self.test.pending = true;
}
self.emit(constants.EVENT_HOOK_END, hook);
return fn(err);
} else {
suite.tests.forEach(function(test) {
test.pending = true;
Expand Down Expand Up @@ -644,7 +650,12 @@ Runner.prototype.runTests = function(suite, fn) {
self.emit(constants.EVENT_TEST_PENDING, test);
}
self.emit(constants.EVENT_TEST_END, test);
return next();
if (err instanceof Pending) {
self.suite = errSuite;
return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
} else {
return next();
}
}
if (err) {
return hookErr(err, errSuite, false);
Expand Down

0 comments on commit db56f38

Please sign in to comment.