Skip to content

Commit 146ffdb

Browse files
author
chenyumic
authored
Setup tests and applied minor fixes for the App Engine Websockets sample (#1865)
See also cl/315382224. Fixes #1825.
1 parent dd7c18b commit 146ffdb

File tree

6 files changed

+52
-3
lines changed

6 files changed

+52
-3
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Set the folder in which the tests are run
4+
env_vars: {
5+
key: "PROJECT"
6+
value: "appengine/websockets"
7+
}
8+
9+
# Tell the trampoline which build file to use.
10+
env_vars: {
11+
key: "TRAMPOLINE_BUILD_FILE"
12+
value: "github/nodejs-docs-samples/.kokoro/build.sh"
13+
}
14+
15+
env_vars: {
16+
key: "TRAMPOLINE_IMAGE"
17+
value: "gcr.io/cloud-devrel-kokoro-resources/node:10-puppeteer"
18+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Set the folder in which the tests are run
4+
env_vars: {
5+
key: "PROJECT"
6+
value: "appengine/websockets"
7+
}
8+
9+
# Tell the trampoline which build file to use.
10+
env_vars: {
11+
key: "TRAMPOLINE_BUILD_FILE"
12+
value: "github/nodejs-docs-samples/.kokoro/build.sh"
13+
}
14+
15+
# Configure the docker image for kokoro-trampoline.
16+
env_vars: {
17+
key: "TRAMPOLINE_IMAGE"
18+
value: "gcr.io/cloud-devrel-kokoro-resources/node:12-puppeteer"
19+
}

appengine/websockets/app.js

+2
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ if (module === require.main) {
3939
});
4040
}
4141
// [END appengine_websockets_app]
42+
43+
module.exports = server

appengine/websockets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Apache Version 2.0",
77
"author": "Google Inc.",
88
"engines": {
9-
"node": ">=8.0.0"
9+
"node": ">=10.18.1"
1010
},
1111
"scripts": {
1212
"deploy": "gcloud app deploy",

appengine/websockets/test/app.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const supertest = require('supertest');
22
const path = require('path');
3-
const app = require(path.join(__dirname, '../', 'app.js'));
3+
const app = require(path.join(path.dirname(__dirname), 'app.js'));
44

55
it('should be listening', async () => {
66
await supertest(app).get('/').expect(200);

appengine/websockets/test/index.test.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,28 @@
1515
'use strict';
1616

1717
const assert = require('assert');
18+
const path = require('path');
19+
const app = require(path.join(path.dirname(__dirname), 'app.js'));
1820
const puppeteer = require('puppeteer');
1921
/* global document */
2022

2123
let browser, browserPage;
2224

2325
before(async () => {
24-
browser = await puppeteer.launch();
26+
const PORT = process.env.PORT || 8080;
27+
app.listen(PORT, () => {});
28+
29+
browser = await puppeteer.launch({
30+
args: [
31+
'--no-sandbox',
32+
'--disable-setuid-sandbox',
33+
]});
2534
browserPage = await browser.newPage();
2635
});
2736

2837
after(async () => {
2938
await browser.close();
39+
await app.close();
3040
});
3141

3242
describe('appengine_websockets_app', () => {

0 commit comments

Comments
 (0)