Skip to content

Commit

Permalink
fix allowUncaught in browser
Browse files Browse the repository at this point in the history
squashed:
- Setup error handler when allowUncaught. (f76afbc)
- Avoid calling done() twice. (dae3428)
  • Loading branch information
lrowe authored and boneskull committed May 9, 2017
1 parent 4ed3fc5 commit fb1e083
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 5 additions & 2 deletions lib/runnable.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,11 @@ Runnable.prototype.run = function (fn) {
}

if (this.allowUncaught) {
callFn(this.fn);
done();
if (this.isPending()) {
done();
} else {
callFn(this.fn);
}
return;
}

Expand Down
7 changes: 3 additions & 4 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,14 @@ Runner.prototype.runTest = function (fn) {
if (this.asyncOnly) {
test.asyncOnly = true;
}

test.on('error', function (err) {
self.fail(test, err);
});
if (this.allowUncaught) {
test.allowUncaught = true;
return test.run(fn);
}
try {
test.on('error', function (err) {
self.fail(test, err);
});
test.run(fn);
} catch (err) {
fn(err);
Expand Down

0 comments on commit fb1e083

Please sign in to comment.