Skip to content

Commit

Permalink
fix(TestRunner): Add try-catch
Browse files Browse the repository at this point in the history
Add try-catch arround mocha's run method  which catches any synchronous errors uncaucht by mocha.
  • Loading branch information
nicojs authored and simondel committed Apr 21, 2017
1 parent 55fd132 commit 0c41fbf
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/stryker-mocha-runner/src/MochaTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ export default class MochaTestRunner implements TestRunner {
this.purgeFiles();
let mocha = new Mocha({ reporter: StrykerMochaReporter });
this.files.forEach(f => mocha.addFile(f));
let runner: any = mocha.run((failures: number) => {
let result: RunResult = runner.runResult;
resolve(result);
});
try {
let runner: any = mocha.run((failures: number) => {
let result: RunResult = runner.runResult;
resolve(result);
});
} catch (error) {
resolve({
result: TestResult.Error,
errorMessages: [error]
});
}
} catch (error) {
log.error(error);
fail();
Expand Down

0 comments on commit 0c41fbf

Please sign in to comment.