From fe2ed3e88ec04937767b6f7ce6ec8e5807a0626a Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Tue, 16 Jul 2019 11:26:53 -0400 Subject: [PATCH] Use supertest instead of repo-tools test app --- appengine/hello-world/standard/app.js | 2 ++ appengine/hello-world/standard/package.json | 6 ++++-- appengine/hello-world/standard/test/app.test.js | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 appengine/hello-world/standard/test/app.test.js diff --git a/appengine/hello-world/standard/app.js b/appengine/hello-world/standard/app.js index 181b3e3b87..281e5fd4c2 100644 --- a/appengine/hello-world/standard/app.js +++ b/appengine/hello-world/standard/app.js @@ -34,3 +34,5 @@ app.listen(PORT, () => { console.log('Press Ctrl+C to quit.'); }); // [END gae_node_request_example] + +module.exports = app; diff --git a/appengine/hello-world/standard/package.json b/appengine/hello-world/standard/package.json index 281cef83b6..ec43fec3b7 100644 --- a/appengine/hello-world/standard/package.json +++ b/appengine/hello-world/standard/package.json @@ -15,7 +15,7 @@ "scripts": { "deploy": "gcloud app deploy", "start": "node app.js", - "system-test": "repo-tools test app", + "system-test": "mocha --exit test/*.test.js", "test": "npm run system-test", "e2e-test": "repo-tools test deploy" }, @@ -23,7 +23,9 @@ "express": "^4.16.3" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "^3.3.0" + "@google-cloud/nodejs-repo-tools": "^3.3.0", + "mocha": "^6.1.4", + "supertest": "^4.0.2" }, "cloud-repo-tools": { "test": { diff --git a/appengine/hello-world/standard/test/app.test.js b/appengine/hello-world/standard/test/app.test.js new file mode 100644 index 0000000000..3bf7b9c3a8 --- /dev/null +++ b/appengine/hello-world/standard/test/app.test.js @@ -0,0 +1,16 @@ +const app = require('../app'); + +const request = require('supertest'); + +describe('GET /', () => { + it('should get 200', done => { + request(app) + .get('/') + .expect(200, done); + }), + it('should get Hello World', done => { + request(app) + .get('/') + .expect('Hello, world!', done); + }); +});