From 9f9894a5878dd87cac5d11a5908830969ade6b96 Mon Sep 17 00:00:00 2001 From: juergba Date: Fri, 27 Sep 2019 11:36:53 +0200 Subject: [PATCH] async Pending handling --- lib/runnable.js | 9 ++++++--- lib/runner.js | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/runnable.js b/lib/runnable.js index a899e860a1..d0f3aebf18 100644 --- a/lib/runnable.js +++ b/lib/runnable.js @@ -350,13 +350,16 @@ Runnable.prototype.run = function(fn) { throw new Pending('async skip; aborting execution'); }; - if (this.allowUncaught) { - return callFnAsync(this.fn); - } try { callFnAsync(this.fn); } catch (err) { + // handles async runnables which actually run synchronously emitted = true; + if (err instanceof Pending) { + return; // done() is already called in this.skip() + } else if (this.allowUncaught) { + throw err; + } done(Runnable.toValueOrError(err)); } return; diff --git a/lib/runner.js b/lib/runner.js index 3afe9e205e..ca447f139b 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -914,8 +914,9 @@ Runner.prototype.run = function(fn) { process.removeListener('uncaughtException', uncaught); process.on('uncaughtException', function(err) { if (err instanceof Pending) { - // return; eslint error + return; } + throw err; }); fn(self.failures); });