Skip to content

Commit

Permalink
chore: refactor typescript test (#1699)
Browse files Browse the repository at this point in the history
  • Loading branch information
sofisl authored Apr 1, 2020
1 parent 86ad6f9 commit d685169
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion appengine/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ app.get("/", (req, res) => {
res.send("🎉 Hello TypeScript! 🎉");
});

app.listen(PORT, () => {
const server = app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
});

module.exports = server;
6 changes: 4 additions & 2 deletions appengine/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"prepare": "npm run gcp-build",
"pretest": "npm run gcp-build",
"test": "repo-tools test app -- index.js",
"test": "mocha test/*.test.js --exit",
"posttest": "npm run lint",
"lint": "tslint -p .",
"start": "node ./index.js",
Expand All @@ -23,8 +23,10 @@
"typescript": "^3.0.1"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
"mocha": "^7.0.0",
"wait-port": "^0.2.7",
"@types/express": "^4.16.0",
"chai": "^4.2.0",
"tslint": "^6.0.0"
}
}
13 changes: 13 additions & 0 deletions appengine/typescript/test/app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const waitPort = require('wait-port');
const {expect} = require('chai');

const PORT = process.env.PORT || 8080;

describe('server listening', () => {
it('should be listening', async () => {
const server = require('../index.js');
const isOpen = await waitPort({port: PORT});
expect(isOpen).to.be.true;
server.close();
});
});

0 comments on commit d685169

Please sign in to comment.