Skip to content

Commit fb1e083

Browse files
lroweboneskull
authored andcommitted
fix allowUncaught in browser
squashed: - Setup error handler when allowUncaught. (f76afbc) - Avoid calling done() twice. (dae3428)
1 parent 4ed3fc5 commit fb1e083

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/runnable.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,11 @@ Runnable.prototype.run = function (fn) {
324324
}
325325

326326
if (this.allowUncaught) {
327-
callFn(this.fn);
328-
done();
327+
if (this.isPending()) {
328+
done();
329+
} else {
330+
callFn(this.fn);
331+
}
329332
return;
330333
}
331334

lib/runner.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,14 @@ Runner.prototype.runTest = function (fn) {
432432
if (this.asyncOnly) {
433433
test.asyncOnly = true;
434434
}
435-
435+
test.on('error', function (err) {
436+
self.fail(test, err);
437+
});
436438
if (this.allowUncaught) {
437439
test.allowUncaught = true;
438440
return test.run(fn);
439441
}
440442
try {
441-
test.on('error', function (err) {
442-
self.fail(test, err);
443-
});
444443
test.run(fn);
445444
} catch (err) {
446445
fn(err);

0 commit comments

Comments
 (0)