File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ const buildGraphql = (
5252 headers
5353} ) ;
5454
55+ const hasExited = ( process : ChildProcess ) => {
56+ return process . exitCode !== null ||
57+ process . signalCode !== null ;
58+ } ;
59+
5560describe ( 'End-to-end server API test' , function ( ) {
5661 // Timeout needs to be long, as first test runs (e.g. in CI) generate
5762 // fresh certificates, which can take a little while.
@@ -101,8 +106,19 @@ describe('End-to-end server API test', function () {
101106 } ) ;
102107 } ) ;
103108
104- afterEach ( ( ) => {
105- if ( ! serverProcess . killed ) serverProcess . kill ( ) ;
109+ afterEach ( async ( ) => {
110+ const killedPromise = new Promise < void > ( ( resolve , reject ) => {
111+ if ( hasExited ( serverProcess ) ) return resolve ( ) ;
112+
113+ serverProcess . on ( 'exit' , resolve ) ;
114+ serverProcess . on ( 'error' , reject ) ;
115+ } ) ;
116+
117+ if ( ! hasExited ( serverProcess ) ) {
118+ serverProcess . kill ( ) ;
119+ await killedPromise ;
120+ }
121+
106122 expect ( stderr ) . to . equal ( '' ) ;
107123 } ) ;
108124
You can’t perform that action at this time.
0 commit comments