@@ -13,7 +13,7 @@ import {
13
13
enableAdminUI ,
14
14
amplifyStudioHeadlessPull ,
15
15
} from '@aws-amplify/amplify-e2e-core' ;
16
- import { spawnSync , spawn , ChildProcessWithoutNullStreams } from 'child_process' ;
16
+ import { spawnSync , spawn } from 'child_process' ;
17
17
import { AmplifyUIBuilder } from 'aws-sdk' ;
18
18
import fs from 'fs-extra' ;
19
19
import path from 'path' ;
@@ -110,28 +110,16 @@ describe('amplify pull with uibuilder', () => {
110
110
fs . readFileSync ( path . join ( __dirname , '..' , 'cypress' , 'uibuilder' , 'uibuilder-spec.js' ) ) ,
111
111
) ;
112
112
113
- let npmStartProcess : ChildProcessWithoutNullStreams ;
114
- let res : execa . ExecaSyncReturnValue < string > ;
115
- describe ( 'cypress tests' , ( ) => {
116
- beforeAll ( async ( ) => {
117
- npmStartProcess = spawn ( getNpmPath ( ) , [ 'start' ] , { cwd : reactDir , timeout : 300000 } ) ;
118
- // Give react server time to start
119
- await new Promise ( ( resolve ) => setTimeout ( resolve , 60000 ) ) ;
120
- } ) ;
121
-
122
- afterAll ( async ( ) => {
123
- // kill the react server process
124
- spawnSync ( 'kill' , [ `${ npmStartProcess . pid } ` ] , { encoding : 'utf8' } ) ;
125
- await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
126
- // Seriously, kill the react server process
127
- // react-scripts somehow resurrects the process automatically after the first kill.
128
- spawnSync ( 'pkill' , [ '-f' , 'react' ] , { encoding : 'utf8' } ) ;
129
- } ) ;
130
-
131
- it ( '...return exit code 0' , ( ) => {
132
- res = execa . sync ( getNpxPath ( ) , [ 'cypress' , 'run' ] , { cwd : reactDir , encoding : 'utf8' } ) ;
133
- expect ( res . exitCode ) . toBe ( 0 ) ;
134
- } ) ;
135
- } ) ;
113
+ const npmStartProcess = spawn ( getNpmPath ( ) , [ 'start' ] , { cwd : reactDir , timeout : 300000 } ) ;
114
+ // Give react server time to start
115
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 60000 ) ) ;
116
+ const res = execa . sync ( getNpxPath ( ) , [ 'cypress' , 'run' ] , { cwd : reactDir , encoding : 'utf8' } ) ;
117
+ // kill the react server process
118
+ spawnSync ( 'kill' , [ `${ npmStartProcess . pid } ` ] , { encoding : 'utf8' } ) ;
119
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
120
+ // Seriously, kill the react server process
121
+ // react-scripts somehow resurrects the process automatically after the first kill.
122
+ spawnSync ( 'pkill' , [ '-f' , 'react' ] , { encoding : 'utf8' } ) ;
123
+ expect ( res . exitCode ) . toBe ( 0 ) ;
136
124
} ) ;
137
125
} ) ;
0 commit comments