Skip to content

Commit 617bc86

Browse files
authored
chore: refactor cloud sql server test (#1692)
1 parent 72631ea commit 617bc86

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

appengine/cloudsql/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,26 @@
1313
"node": ">=8.0.0"
1414
},
1515
"scripts": {
16-
"unit-test": "mocha test/*.test.js --timeout=60000",
16+
"unit-test": "mocha test/createTables.test.js --timeout=60000 && 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
"mysql": "^2.16.0",
2728
"prompt": "^1.0.0"
2829
},
2930
"devDependencies": {
30-
"@google-cloud/nodejs-repo-tools": "^3.3.0",
3131
"mocha": "^7.0.0",
3232
"proxyquire": "^2.1.0",
3333
"sinon": "^9.0.0",
34-
"supertest": "^4.0.0"
34+
"supertest": "^4.0.0",
35+
"wait-port": "^0.2.7"
3536
},
3637
"cloud-repo-tools": {
3738
"requiresKeyFile": true,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const waitPort = require('wait-port');
2+
const {expect} = require('chai');
3+
4+
describe('server listening', () => {
5+
it('should be listening', async () => {
6+
require('../server.js');
7+
const isOpen = await waitPort({port: 8080});
8+
expect(isOpen).to.be.true;
9+
});
10+
});

0 commit comments

Comments
 (0)