@@ -95,11 +95,8 @@ const CompletedTests: React.FC<{
95
95
let testOutputs = completedTests . map ( ( { testResult, config } ) => (
96
96
< React . Fragment key = { testResult . testFilePath + config . name } >
97
97
< ResultHeader config = { config } testResult = { testResult } />
98
- < VerboseTestList
99
- testResult = { testResult }
100
- globalConfig = { globalConfig }
101
- />
102
- < TestConsoleOutput
98
+ < VerboseTestList testResult = { testResult } globalConfig = { globalConfig } />
99
+ < TestConsoleOutput
103
100
console = { testResult . console }
104
101
verbose = { globalConfig . verbose }
105
102
cwd = { config . cwd }
@@ -219,6 +216,26 @@ const RunningTests: React.FC<{
219
216
) ;
220
217
} ;
221
218
219
+ const Exiter : React . FC < { done : boolean } > = ( { done } ) => {
220
+ const { exit } = useApp ( ) ;
221
+
222
+ const [ shouldExit , setShouldExit ] = React . useState ( false ) ;
223
+
224
+ React . useEffect ( ( ) => {
225
+ if ( done ) {
226
+ setShouldExit ( true ) ;
227
+ }
228
+ } , [ done , exit ] ) ;
229
+
230
+ React . useEffect ( ( ) => {
231
+ if ( shouldExit ) {
232
+ exit ( ) ;
233
+ }
234
+ } , [ exit , shouldExit ] ) ;
235
+
236
+ return null ;
237
+ } ;
238
+
222
239
const Reporter : React . FC < Props > = ( {
223
240
register,
224
241
globalConfig,
@@ -249,13 +266,6 @@ const Reporter: React.FC<Props> = ({
249
266
} = state ;
250
267
const { estimatedTime = 0 } = options ;
251
268
252
- const { exit } = useApp ( ) ;
253
- React . useEffect ( ( ) => {
254
- if ( done ) {
255
- setImmediate ( exit ) ;
256
- }
257
- } , [ done , exit ] ) ;
258
-
259
269
const summary = (
260
270
< Summary
261
271
aggregatedResults = { aggregatedResults }
@@ -280,6 +290,7 @@ const Reporter: React.FC<Props> = ({
280
290
/>
281
291
< RunningTests tests = { currentTests } width = { width } />
282
292
{ done ? null : summary }
293
+ < Exiter done = { done } />
283
294
</ Box >
284
295
) ;
285
296
} ;
0 commit comments