diff --git a/appengine/pubsub/package.json b/appengine/pubsub/package.json index 08c080242d..9586e17a4f 100644 --- a/appengine/pubsub/package.json +++ b/appengine/pubsub/package.json @@ -10,18 +10,20 @@ }, "scripts": { "start": "node app.js", - "test": "repo-tools test app && mocha test/app.test.js --timeout=30000 --exit" + "test": "mocha test/*.test.js --timeout=30000 --exit" }, "dependencies": { "@google-cloud/pubsub": "^1.0.0", "body-parser": "^1.18.3", "express": "^4.16.3", "google-auth-library": "^6.0.0", - "pug": "^2.0.1" + "path": "^0.12.7", + "pug": "^2.0.1", + "wait-port": "^0.2.7" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "^3.3.0", "jsonwebtoken": "^8.5.1", + "chai": "^4.2.0", "mocha": "^7.0.0", "sinon": "^9.0.0", "uuid": "^7.0.0", diff --git a/appengine/pubsub/test/appListening.test.js b/appengine/pubsub/test/appListening.test.js new file mode 100644 index 0000000000..0198ff4fe6 --- /dev/null +++ b/appengine/pubsub/test/appListening.test.js @@ -0,0 +1,14 @@ +const waitPort = require('wait-port'); +const {expect} = require('chai'); +const PORT = process.env.PORT || 8080; +const childProcess = require('child_process'); +const path = require('path'); +const appPath = path.join(__dirname, '../app.js'); + +describe('server listening', () => { + it('should be listening', async () => { + await childProcess.exec(`node ${appPath}`); + const isOpen = await waitPort({port: PORT}); + expect(isOpen).to.be.true; + }); +});