File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 },
1111 "scripts" : {
1212 "start" : " node app.js" ,
13- "test" : " repo-tools test app && mocha test/app .test.js --timeout=30000 --exit"
13+ "test" : " mocha test/* .test.js --timeout=30000 --exit"
1414 },
1515 "dependencies" : {
1616 "@google-cloud/pubsub" : " ^1.0.0" ,
1717 "body-parser" : " ^1.18.3" ,
1818 "express" : " ^4.16.3" ,
1919 "google-auth-library" : " ^6.0.0" ,
20- "pug" : " ^2.0.1"
20+ "path" : " ^0.12.7" ,
21+ "pug" : " ^2.0.1" ,
22+ "wait-port" : " ^0.2.7"
2123 },
2224 "devDependencies" : {
23- "@google-cloud/nodejs-repo-tools" : " ^3.3.0" ,
2425 "jsonwebtoken" : " ^8.5.1" ,
26+ "chai" : " ^4.2.0" ,
2527 "mocha" : " ^7.0.0" ,
2628 "sinon" : " ^9.0.0" ,
2729 "uuid" : " ^7.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 , '../app.js' ) ;
7+
8+ describe ( 'server listening' , ( ) => {
9+ it ( 'should be listening' , async ( ) => {
10+ await childProcess . exec ( `node ${ appPath } ` ) ;
11+ const isOpen = await waitPort ( { port : PORT } ) ;
12+ expect ( isOpen ) . to . be . true ;
13+ } ) ;
14+ } ) ;
You can’t perform that action at this time.
0 commit comments