File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
appengine/cloudsql_postgresql Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 1313 "node" : " >=8.0.0"
1414 },
1515 "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 " ,
1717 "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 " ,
1919 "system-test-proxy" : " npm run start-proxy; npm run system-test" ,
2020 "all-test" : " npm run unit-test && npm run system-test" ,
2121 "test" : " npm -- run all-test"
2222 },
2323 "dependencies" : {
24+ "chai" : " ^4.2.0" ,
2425 "express" : " ^4.16.4" ,
2526 "knex" : " ^0.20.0" ,
2627 "pg" : " ^8.0.0" ,
27- "prompt" : " ^1.0.0"
28+ "prompt" : " ^1.0.0" ,
29+ "wait-port" : " ^0.2.7"
2830 },
2931 "devDependencies" : {
30- "@google-cloud/nodejs-repo-tools" : " ^3.3.0" ,
3132 "mocha" : " ^7.0.0" ,
3233 "proxyquire" : " ^2.1.0" ,
3334 "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