@@ -49,7 +49,7 @@ export type TestRunnerOptions = {|
49
49
startRun : ( globalConfig : GlobalConfig ) => * ,
50
50
| } ;
51
51
52
- type OnTestFailure = ( test : Test , err : TestError ) => void ;
52
+ type OnTestFailure = ( test : Test , err : TestError ) => Promise < * > ;
53
53
type OnTestSuccess = ( test : Test , result : TestResult ) => Promise < * > ;
54
54
55
55
const TEST_WORKER_PATH = require . resolve ( './test_worker' ) ;
@@ -99,24 +99,24 @@ class TestRunner {
99
99
timings . length > 0 &&
100
100
timings . every ( timing => timing < SLOW_TEST_TIME ) ) ;
101
101
102
- const onResult = ( test : Test , testResult : TestResult ) => {
102
+ const onResult = async ( test : Test , testResult : TestResult ) => {
103
103
if ( watcher . isInterrupted ( ) ) {
104
104
return Promise . resolve ( ) ;
105
105
}
106
106
if ( testResult . testResults . length === 0 ) {
107
107
const message = 'Your test suite must contain at least one test.' ;
108
- onFailure ( test , {
108
+ await onFailure ( test , {
109
109
message,
110
110
stack : new Error ( message ) . stack ,
111
111
} ) ;
112
112
return Promise . resolve ( ) ;
113
113
}
114
114
addResult ( aggregatedResults , testResult ) ;
115
- this . _dispatcher . onTestResult ( test , testResult , aggregatedResults ) ;
115
+ await this . _dispatcher . onTestResult ( test , testResult , aggregatedResults ) ;
116
116
return this . _bailIfNeeded ( contexts , aggregatedResults , watcher ) ;
117
117
} ;
118
118
119
- const onFailure = ( test : Test , error : TestError ) => {
119
+ const onFailure = async ( test : Test , error : TestError ) => {
120
120
if ( watcher . isInterrupted ( ) ) {
121
121
return ;
122
122
}
@@ -128,7 +128,7 @@ class TestRunner {
128
128
test . path ,
129
129
) ;
130
130
addResult ( aggregatedResults , testResult ) ;
131
- this . _dispatcher . onTestResult ( test , testResult , aggregatedResults ) ;
131
+ await this . _dispatcher . onTestResult ( test , testResult , aggregatedResults ) ;
132
132
} ;
133
133
134
134
const updateSnapshotState = ( ) => {
@@ -149,7 +149,7 @@ class TestRunner {
149
149
) ;
150
150
} ;
151
151
152
- this . _dispatcher . onRunStart ( aggregatedResults , {
152
+ await this . _dispatcher . onRunStart ( aggregatedResults , {
153
153
estimatedTime,
154
154
showStatus : ! runInBand ,
155
155
} ) ;
@@ -194,12 +194,12 @@ class TestRunner {
194
194
( promise , test ) =>
195
195
mutex ( ( ) =>
196
196
promise
197
- . then ( ( ) => {
197
+ . then ( async ( ) => {
198
198
if ( watcher . isInterrupted ( ) ) {
199
199
throw new CancelRun ( ) ;
200
200
}
201
201
202
- this . _dispatcher . onTestStart ( test ) ;
202
+ await this . _dispatcher . onTestStart ( test ) ;
203
203
return runTest (
204
204
test . path ,
205
205
this . _globalConfig ,
@@ -235,11 +235,11 @@ class TestRunner {
235
235
// Send test suites to workers continuously instead of all at once to track
236
236
// the start time of individual tests.
237
237
const runTestInWorker = test =>
238
- mutex ( ( ) => {
238
+ mutex ( async ( ) => {
239
239
if ( watcher . isInterrupted ( ) ) {
240
240
return Promise . reject ( ) ;
241
241
}
242
- this . _dispatcher . onTestStart ( test ) ;
242
+ await this . _dispatcher . onTestStart ( test ) ;
243
243
return worker ( {
244
244
config : test . context . config ,
245
245
globalConfig : this . _globalConfig ,
@@ -250,8 +250,8 @@ class TestRunner {
250
250
} ) ;
251
251
} ) ;
252
252
253
- const onError = ( err , test ) => {
254
- onFailure ( test , err ) ;
253
+ const onError = async ( err , test ) => {
254
+ await onFailure ( test , err ) ;
255
255
if ( err . type === 'ProcessTerminatedError' ) {
256
256
console . error (
257
257
'A worker process has quit unexpectedly! ' +
0 commit comments