File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,27 @@ const RunningTests: React.FC<{
222
222
) ;
223
223
} ;
224
224
225
+ const Exiter : React . FC < { done : boolean } > = ( { done } ) => {
226
+ const { exit } = useApp ( ) ;
227
+
228
+ const [ shouldExit , setShouldExit ] = React . useState ( false ) ;
229
+
230
+ // use a separate effect to ensure output is properly flushed. This _might_ be a bug in Ink, not sure
231
+ React . useEffect ( ( ) => {
232
+ if ( done ) {
233
+ setShouldExit ( true ) ;
234
+ }
235
+ } , [ done , exit ] ) ;
236
+
237
+ React . useEffect ( ( ) => {
238
+ if ( shouldExit ) {
239
+ exit ( ) ;
240
+ }
241
+ } , [ exit , shouldExit ] ) ;
242
+
243
+ return null ;
244
+ } ;
245
+
225
246
const Reporter : React . FC < Props > = ( {
226
247
register,
227
248
globalConfig,
@@ -247,13 +268,6 @@ const Reporter: React.FC<Props> = ({
247
268
state ;
248
269
const { estimatedTime = 0 } = options ;
249
270
250
- const { exit } = useApp ( ) ;
251
- React . useEffect ( ( ) => {
252
- if ( done ) {
253
- setImmediate ( exit ) ;
254
- }
255
- } , [ done , exit ] ) ;
256
-
257
271
const summary = (
258
272
< Summary
259
273
aggregatedResults = { aggregatedResults }
@@ -278,6 +292,7 @@ const Reporter: React.FC<Props> = ({
278
292
/>
279
293
< RunningTests tests = { currentTests } width = { width } />
280
294
{ done ? null : summary }
295
+ < Exiter done = { done } />
281
296
</ Box >
282
297
) ;
283
298
} ;
You can’t perform that action at this time.
0 commit comments