From fb1e0830b5e235326b58b25da9f07c42da363404 Mon Sep 17 00:00:00 2001 From: Laurence Rowe Date: Tue, 31 Jan 2017 19:26:05 -0800 Subject: [PATCH] fix allowUncaught in browser squashed: - Setup error handler when allowUncaught. (f76afbc) - Avoid calling done() twice. (dae3428) --- lib/runnable.js | 7 +++++-- lib/runner.js | 7 +++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/runnable.js b/lib/runnable.js index e7b6aa12f0..ee8c4a3467 100644 --- a/lib/runnable.js +++ b/lib/runnable.js @@ -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; } diff --git a/lib/runner.js b/lib/runner.js index 1d3dd959da..b024e0dcb5 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -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);