Skip to content

Commit b27cb8d

Browse files
yovasx2novemberborn
authored andcommitted
Print internal errors when precompiler setup or globbing fails
1 parent 8628976 commit b27cb8d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/api.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Api extends Emittery {
5151
}
5252

5353
async run(files = [], runtimeOptions = {}) {
54+
let setupOrGlobError;
5455
files = files.map(file => path.resolve(this.options.resolveTestsFrom, file));
5556

5657
const apiOptions = this.options;
@@ -106,9 +107,12 @@ class Api extends Emittery {
106107
}
107108
};
108109

110+
let precompiler;
111+
let helpers;
112+
109113
try {
110-
const precompiler = await this._setupPrecompiler();
111-
let helpers = [];
114+
precompiler = await this._setupPrecompiler(); // eslint-disable-line require-atomic-updates
115+
helpers = [];
112116
if (files.length === 0 || precompiler.enabled) {
113117
let found;
114118
if (precompiler.enabled) {
@@ -122,7 +126,12 @@ class Api extends Emittery {
122126
({tests: files} = found);
123127
}
124128
}
129+
} catch (error) {
130+
files = [];
131+
setupOrGlobError = error;
132+
}
125133

134+
try {
126135
if (this.options.parallelRuns) {
127136
const {currentIndex, totalRuns} = this.options.parallelRuns;
128137
const fileCount = files.length;
@@ -150,6 +159,10 @@ class Api extends Emittery {
150159
status: runStatus
151160
});
152161

162+
if (setupOrGlobError) {
163+
throw setupOrGlobError;
164+
}
165+
153166
// Bail out early if no files were found.
154167
if (files.length === 0) {
155168
return runStatus;

0 commit comments

Comments
 (0)