File tree 2 files changed +20
-4
lines changed
appengine/cloudsql_postgresql
2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 13
13
"node" : " >=8.0.0"
14
14
},
15
15
"scripts" : {
16
- "unit-test" : " mocha test/* .test.js --timeout=30000" ,
16
+ "unit-test" : " mocha test/createTables .test.js --timeout=30000 && mocha test/server.test.js " ,
17
17
"start-proxy" : " ! pgrep cloud_sql_proxy > /dev/null && cloud_sql_proxy -instances=$INSTANCE_CONNECTION_NAME=tcp:$SQL_PORT &" ,
18
- "system-test" : " repo-tools test app -- server.js " ,
18
+ "system-test" : " mocha test/serverListening.test.js --exit " ,
19
19
"system-test-proxy" : " npm run start-proxy; npm run system-test" ,
20
20
"all-test" : " npm run unit-test && npm run system-test" ,
21
21
"test" : " npm -- run all-test"
22
22
},
23
23
"dependencies" : {
24
+ "chai" : " ^4.2.0" ,
24
25
"express" : " ^4.16.4" ,
25
26
"knex" : " ^0.20.0" ,
26
27
"pg" : " ^8.0.0" ,
27
- "prompt" : " ^1.0.0"
28
+ "prompt" : " ^1.0.0" ,
29
+ "wait-port" : " ^0.2.7"
28
30
},
29
31
"devDependencies" : {
30
- "@google-cloud/nodejs-repo-tools" : " ^3.3.0" ,
31
32
"mocha" : " ^7.0.0" ,
32
33
"proxyquire" : " ^2.1.0" ,
33
34
"sinon" : " ^9.0.0" ,
Original file line number Diff line number Diff line change
1
+ const waitPort = require ( 'wait-port' ) ;
2
+ const { expect} = require ( 'chai' ) ;
3
+ const PORT = process . env . PORT || 8080 ;
4
+ const childProcess = require ( 'child_process' ) ;
5
+ const path = require ( 'path' ) ;
6
+ const appPath = path . join ( __dirname , '../server.js' ) ;
7
+
8
+ describe ( 'server listening' , ( ) => {
9
+ it ( 'should be listening' , async ( ) => {
10
+ const child = childProcess . exec ( `node ${ appPath } ` ) ;
11
+ const isOpen = await waitPort ( { port : PORT } ) ;
12
+ expect ( isOpen ) . to . be . true ;
13
+ process . kill ( child . pid , 'SIGTERM' ) ;
14
+ } ) ;
15
+ } ) ;
You can’t perform that action at this time.
0 commit comments