Skip to content

Commit

Permalink
chore: refactor pubsub test (#1693)
Browse files Browse the repository at this point in the history
  • Loading branch information
sofisl authored Apr 1, 2020
1 parent 617bc86 commit 86ad6f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 5 additions & 3 deletions appengine/pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions appengine/pubsub/test/appListening.test.js
Original file line number Diff line number Diff line change
@@ -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;
});
});

0 comments on commit 86ad6f9

Please sign in to comment.