Skip to content

Commit aa94318

Browse files
asztaljuhovh
authored andcommitted
Fix crash when running with mocha --parallel
I hope this is a reasonable change. It seems mocha 8.0 doesn't provide a list of tests in the `suite` event when running in parallel mode. However, it seems that mocha-jenkins-reporter doesn't desparately need this data, as it seems to still work for me with this change.
1 parent 70bd785 commit aa94318

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/jenkins.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,18 @@ function Jenkins(runner, options) {
168168
}
169169

170170
function startSuite(suite) {
171-
if (suite.tests.length > 0) {
172-
currentSuite = {
173-
suite: suite,
174-
tests: [],
175-
start: new Date,
176-
failures: 0,
177-
passes: 0
178-
};
179-
log();
180-
log(" "+suite.fullTitle());
181-
}
171+
if (suite.tests && suite.tests.length === 0)
172+
return;
173+
174+
currentSuite = {
175+
suite: suite,
176+
tests: [],
177+
start: new Date,
178+
failures: 0,
179+
passes: 0
180+
};
181+
log();
182+
log(" "+suite.fullTitle());
182183
}
183184

184185
function endSuite() {

0 commit comments

Comments
 (0)