From b27cb8d538c58743ba3f5d46e0523e7a0ca5982c Mon Sep 17 00:00:00 2001 From: Giovanni Alberto Date: Sun, 11 Aug 2019 09:25:58 -0500 Subject: [PATCH] Print internal errors when precompiler setup or globbing fails --- lib/api.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index c9cb29295..d1ac93ae1 100644 --- a/lib/api.js +++ b/lib/api.js @@ -51,6 +51,7 @@ class Api extends Emittery { } async run(files = [], runtimeOptions = {}) { + let setupOrGlobError; files = files.map(file => path.resolve(this.options.resolveTestsFrom, file)); const apiOptions = this.options; @@ -106,9 +107,12 @@ class Api extends Emittery { } }; + let precompiler; + let helpers; + try { - const precompiler = await this._setupPrecompiler(); - let helpers = []; + precompiler = await this._setupPrecompiler(); // eslint-disable-line require-atomic-updates + helpers = []; if (files.length === 0 || precompiler.enabled) { let found; if (precompiler.enabled) { @@ -122,7 +126,12 @@ class Api extends Emittery { ({tests: files} = found); } } + } catch (error) { + files = []; + setupOrGlobError = error; + } + try { if (this.options.parallelRuns) { const {currentIndex, totalRuns} = this.options.parallelRuns; const fileCount = files.length; @@ -150,6 +159,10 @@ class Api extends Emittery { status: runStatus }); + if (setupOrGlobError) { + throw setupOrGlobError; + } + // Bail out early if no files were found. if (files.length === 0) { return runStatus;