Skip to content

Commit 86ad6f9

Browse files
authored
chore: refactor pubsub test (GoogleCloudPlatform#1693)
1 parent 617bc86 commit 86ad6f9

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

appengine/pubsub/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
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",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
});

0 commit comments

Comments
 (0)