@@ -24,7 +24,7 @@ let Mocha: any; // Late init with "mocha" or "mocha-parallel-tests"
24
24
chai . use ( require ( "./assertions" ) . default ) ;
25
25
26
26
type CreateInTestDebugFunction = ( options : {
27
- mochaRunner : any ;
27
+ mochaRunner : Promise < unknown > ;
28
28
config : Config ;
29
29
compilations : Compilation [ ] ;
30
30
} ) => ( operation : any ) => any ;
@@ -90,6 +90,17 @@ export const Test = {
90
90
91
91
const mocha = this . createMocha ( config ) ;
92
92
93
+ // set up a promise on this instance to resolve to
94
+ // Mocha's "runner" returned by `mocha.run(...)`.
95
+ //
96
+ // do this upfront so that the promise is available
97
+ // immediately, even though mocha.run happens at the very
98
+ // end of this setup.
99
+ let setMochaRunner : ( mochaRunner : unknown ) => void ;
100
+ this . mochaRunner = new Promise ( resolve => {
101
+ setMochaRunner = resolve ;
102
+ } ) ;
103
+
93
104
const jsTests = config . test_files . filter ( ( file : string ) => {
94
105
return path . extname ( file ) !== ".sol" ;
95
106
} ) ;
@@ -177,10 +188,14 @@ export const Test = {
177
188
} ) ;
178
189
179
190
return new Promise ( resolve => {
180
- this . mochaRunner = mocha . run ( ( failures : number ) => {
191
+ const mochaRunner = mocha . run ( ( failures : number ) => {
181
192
config . logger . warn = warn ;
182
193
resolve ( failures ) ;
183
194
} ) ;
195
+
196
+ // finish setting up the mocha runner so that the
197
+ // previously-made promise resolves.
198
+ setMochaRunner ( mochaRunner ) ;
184
199
} ) ;
185
200
} ,
186
201
0 commit comments