@@ -39,21 +39,26 @@ env.PORT = 3001;
3939const server = cp . spawn ( 'node' , [ 'demo/start' ] , {
4040 cwd : path . resolve ( __dirname , '..' ) ,
4141 env,
42- stdio : 'inherit '
42+ stdio : 'pipe '
4343} )
4444
45- const run = cp . spawnSync (
46- npmBinScript ( 'mocha' ) ,
47- [ ...testFiles , ...flagArgs ] ,
48- {
49- cwd : path . resolve ( __dirname , '..' ) ,
50- env,
51- stdio : 'inherit'
52- }
53- ) ;
45+ server . stdout . on ( 'data' , ( data ) => {
46+ // await for the server to fully start
47+ if ( data . indexOf ( "successfully" ) !== - 1 ) {
48+ const run = cp . spawnSync (
49+ npmBinScript ( 'mocha' ) ,
50+ [ ...testFiles , ...flagArgs ] , {
51+ cwd : path . resolve ( __dirname , '..' ) ,
52+ env,
53+ stdio : 'inherit'
54+ }
55+ ) ;
5456
55- function npmBinScript ( script ) {
56- return path . resolve ( __dirname , `../node_modules/.bin/` + ( process . platform === 'win32' ? `${ script } .cmd` : script ) ) ;
57- }
57+ function npmBinScript ( script ) {
58+ return path . resolve ( __dirname , `../node_modules/.bin/` + ( process . platform === 'win32' ?
59+ `${ script } .cmd` : script ) ) ;
60+ }
5861
59- process . exit ( run . status ) ;
62+ process . exit ( run . status ) ;
63+ }
64+ } ) ;
0 commit comments