@@ -7,31 +7,36 @@ import * as path from 'path';
7
7
import { setupTestCoreApi } from './setupTestCoreApi' ;
8
8
9
9
export async function run ( ) : Promise < void > {
10
- setupTestCoreApi ( ) ;
11
-
12
- const options : Mocha . MochaOptions = {
13
- color : true ,
14
- reporter : 'mocha-multi-reporters' ,
15
- reporterOptions : {
16
- reporterEnabled : 'spec, mocha-junit-reporter' ,
17
- mochaJunitReporterReporterOptions : {
18
- mochaFile : path . resolve ( __dirname , '..' , '..' , 'test' , 'unit-test-results.xml' ) ,
10
+ try {
11
+ setupTestCoreApi ( ) ;
12
+
13
+ const options : Mocha . MochaOptions = {
14
+ color : true ,
15
+ reporter : 'mocha-multi-reporters' ,
16
+ reporterOptions : {
17
+ reporterEnabled : 'spec, mocha-junit-reporter' ,
18
+ mochaJunitReporterReporterOptions : {
19
+ mochaFile : path . resolve ( __dirname , '..' , '..' , 'test' , 'unit-test-results.xml' ) ,
20
+ } ,
19
21
} ,
20
- } ,
21
- } ;
22
+ } ;
22
23
23
- addEnvVarsToMochaOptions ( options ) ;
24
- console . log ( `Mocha options: ${ JSON . stringify ( options , undefined , 2 ) } ` ) ;
24
+ addEnvVarsToMochaOptions ( options ) ;
25
+ console . log ( `Mocha options: ${ JSON . stringify ( options , undefined , 2 ) } ` ) ;
25
26
26
- const mocha = new Mocha ( options ) ;
27
+ const mocha = new Mocha ( options ) ;
27
28
28
- const files : string [ ] = await globby ( '**/**.test.js' , { cwd : __dirname } ) ;
29
+ const files : string [ ] = await globby ( '**/**.test.js' , { cwd : __dirname } ) ;
29
30
30
- files . forEach ( ( f ) => mocha . addFile ( path . resolve ( __dirname , f ) ) ) ;
31
+ files . forEach ( ( f ) => mocha . addFile ( path . resolve ( __dirname , f ) ) ) ;
31
32
32
- const failures = await new Promise < number > ( ( resolve ) => mocha . run ( resolve ) ) ;
33
- if ( failures > 0 ) {
34
- throw new Error ( `${ failures } tests failed.` ) ;
33
+ const failures = await new Promise < number > ( ( resolve ) => mocha . run ( resolve ) ) ;
34
+ if ( failures > 0 ) {
35
+ throw new Error ( `${ failures } tests failed.` ) ;
36
+ }
37
+ } catch ( err ) {
38
+ console . error ( 'Test run failed' ) ;
39
+ process . exit ( 1 ) ;
35
40
}
36
41
}
37
42
0 commit comments