@@ -34,19 +34,31 @@ if (process.argv.length > 2) {
3434
3535
3636env . DEBUG = flagArgs . indexOf ( '--debug' ) >= 0 ? 'debug' : '' ;
37+ env . PORT = 3001 ;
3738
38- const run = cp . spawnSync (
39- npmBinScript ( 'mocha' ) ,
40- [ ...testFiles , ...flagArgs ] ,
41- {
42- cwd : path . resolve ( __dirname , '..' ) ,
43- env,
44- stdio : 'inherit'
45- }
46- ) ;
39+ const server = cp . spawn ( 'node' , [ 'demo/start' ] , {
40+ cwd : path . resolve ( __dirname , '..' ) ,
41+ env,
42+ stdio : 'pipe'
43+ } )
4744
48- function npmBinScript ( script ) {
49- return path . resolve ( __dirname , `../node_modules/.bin/` + ( process . platform === 'win32' ? `${ script } .cmd` : script ) ) ;
50- }
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+ ) ;
5156
52- process . exit ( run . status ) ;
57+ function npmBinScript ( script ) {
58+ return path . resolve ( __dirname , `../node_modules/.bin/` + ( process . platform === 'win32' ?
59+ `${ script } .cmd` : script ) ) ;
60+ }
61+
62+ process . exit ( run . status ) ;
63+ }
64+ } ) ;
0 commit comments