Skip to content

Commit 4be3cc8

Browse files
author
Benjamin Pasero
committed
test - convert web integration to TS
1 parent ca51443 commit 4be3cc8

9 files changed

Lines changed: 241 additions & 34 deletions

File tree

.eslintrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,13 @@
614614
"*"
615615
]
616616
},
617+
{
618+
"target": "**/test/integration/**",
619+
"restrictions": [
620+
"**/test/integration/**",
621+
"*"
622+
]
623+
},
617624
{
618625
"target": "{**/api/**.test.ts,}",
619626
"restrictions": "{**/vs/**,assert,sinon,crypto,vscode}"

build/npm/postinstall.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@ runtime "${runtime}"`;
7272
yarnInstall(`build`); // node modules required for build
7373
yarnInstall('test/automation'); // node modules required for smoketest
7474
yarnInstall('test/smoke'); // node modules required for smoketest
75+
yarnInstall('test/integration/browser'); // node modules required for integration
7576
yarnInstallBuildDependencies(); // node modules for watching, specific to host node version, not electron
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
npm-debug.log
3+
Thumbs.db
4+
node_modules/
5+
out/

test/integration/browser/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# VS Code Integration test
2+
3+
### Run
4+
5+
```bash
6+
7+
# Dev (Electron)
8+
scripts/test-integration.sh
9+
10+
# Dev (Web)
11+
node test/integration/browser/out/index.js
12+
13+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "code-oss-dev-integration-test",
3+
"version": "0.1.0",
4+
"main": "./index.js",
5+
"scripts": {
6+
"postinstall": "npm run compile",
7+
"compile": "yarn tsc"
8+
},
9+
"devDependencies": {
10+
"@types/mkdirp": "0.5.1",
11+
"@types/node": "^12.11.7",
12+
"@types/rimraf": "2.0.2",
13+
"rimraf": "^2.6.1",
14+
"tmp": "0.0.33",
15+
"typescript": "3.7.5"
16+
}
17+
}
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,19 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
//@ts-check
6+
import * as path from 'path';
7+
import * as cp from 'child_process';
8+
import * as playwright from 'playwright';
9+
import * as url from 'url';
10+
import * as tmp from 'tmp';
11+
import * as rimraf from 'rimraf';
712

8-
const path = require('path');
9-
const cp = require('child_process');
10-
const playwright = require('playwright');
11-
const url = require('url');
12-
13-
// opts
1413
const optimist = require('optimist')
1514
.describe('debug', 'do not run browsers headless').boolean('debug')
1615
.describe('browser', 'browser in which integration tests should run').string('browser').default('browser', 'chromium')
1716
.describe('help', 'show the help').alias('help', 'h');
1817

19-
// logic
20-
const argv = optimist.argv;
21-
22-
let serverProcess;
18+
let serverProcess: cp.ChildProcess | undefined = undefined;
2319

2420
function teardownServer() {
2521
if (serverProcess) {
@@ -28,18 +24,17 @@ function teardownServer() {
2824
}
2925
}
3026

31-
/**
32-
* @param {string} browserType
33-
* @param {string} endpoint
34-
*/
35-
async function runTestsInBrowser(browserType, endpoint) {
36-
const browser = await playwright[browserType].launch({ headless: !Boolean(argv.debug) });
27+
async function runTestsInBrowser(browserType: string, endpoint: string): Promise<void> {
28+
const browser = await playwright[browserType].launch({ headless: !Boolean(optimist.argv.debug) });
3729
const page = (await browser.defaultContext().pages())[0];
3830

39-
const integrationTestsPath = path.join(__dirname, '..', '..', '..', 'extensions', 'vscode-api-tests');
40-
const testWorkspaceUri = url.format({ pathname: path.join(integrationTestsPath, 'testWorkspace'), protocol: 'vscode-remote:', slashes: true, host: 'localhost:9888' });
41-
const testExtensionUri = url.format({ pathname: path.join(integrationTestsPath), protocol: 'vscode-remote:', slashes: true, host: 'localhost:9888' });
42-
const testFilesUri = url.format({ pathname: path.join(integrationTestsPath, 'out', 'singlefolder-tests'), protocol: 'vscode-remote:', slashes: true, host: 'localhost:9888' });
31+
const host = url.parse(endpoint).host;
32+
const protocol = 'vscode-remote';
33+
34+
const integrationTestsPath = path.join(__dirname, '..', '..', '..', '..', 'extensions', 'vscode-api-tests');
35+
const testWorkspaceUri = url.format({ pathname: path.join(integrationTestsPath, 'testWorkspace'), protocol, host, slashes: true });
36+
const testExtensionUri = url.format({ pathname: path.join(integrationTestsPath), protocol, host, slashes: true });
37+
const testFilesUri = url.format({ pathname: path.join(integrationTestsPath, 'out', 'singlefolder-tests'), protocol, host, slashes: true });
4338

4439
const folderParam = testWorkspaceUri;
4540
const payloadParam = `[["extensionDevelopmentPath","${testExtensionUri}"],["extensionTestsPath","${testFilesUri}"]]`;
@@ -51,7 +46,7 @@ async function runTestsInBrowser(browserType, endpoint) {
5146
// emitter.emit(type, data1, data2)
5247
// });
5348

54-
page.on('console', async msg => {
49+
page.on('console', async (msg: playwright.ConsoleMessage) => {
5550
const msgText = msg.text();
5651
console[msg.type()](msgText, await Promise.all(msg.args().map(async arg => await arg.jsonValue())));
5752

@@ -63,20 +58,25 @@ async function runTestsInBrowser(browserType, endpoint) {
6358
});
6459
}
6560

66-
async function launch() {
67-
// workspacePath = _workspacePath;
68-
// const agentFolder = userDataDir;
69-
// await promisify(mkdir)(agentFolder);
61+
async function launchServer(): Promise<string> {
62+
const tmpDir = tmp.dirSync({ prefix: 't' });
63+
const testDataPath = tmpDir.name;
64+
process.once('exit', () => rimraf.sync(testDataPath));
65+
66+
const userDataDir = path.join(testDataPath, 'd');
67+
7068
const env = {
71-
// VSCODE_AGENT_FOLDER: agentFolder,
69+
VSCODE_AGENT_FOLDER: userDataDir,
7270
...process.env
7371
};
7472

7573
let serverLocation;
7674
if (process.env.VSCODE_REMOTE_SERVER_PATH) {
7775
serverLocation = path.join(process.env.VSCODE_REMOTE_SERVER_PATH, `server.${process.platform === 'win32' ? 'cmd' : 'sh'}`);
7876
} else {
79-
serverLocation = path.join(__dirname, '..', '..', '..', `resources/server/web.${process.platform === 'win32' ? 'bat' : 'sh'}`);
77+
serverLocation = path.join(__dirname, '..', '..', '..', '..', `resources/server/web.${process.platform === 'win32' ? 'bat' : 'sh'}`);
78+
79+
process.env.VSCODE_DEV = '1';
8080
}
8181

8282
serverProcess = cp.spawn(
@@ -85,15 +85,15 @@ async function launch() {
8585
{ env }
8686
);
8787

88-
serverProcess.stderr.on('data', e => console.log('Server stderr: ' + e));
89-
serverProcess.stdout.on('data', e => console.log('Server stdout: ' + e));
88+
serverProcess?.stderr?.on('data', e => console.log(`Server stderr: ${e}`));
89+
serverProcess?.stdout?.on('data', e => console.log(`Server stdout: ${e}`));
9090

9191
process.on('exit', teardownServer);
9292
process.on('SIGINT', teardownServer);
9393
process.on('SIGTERM', teardownServer);
9494

9595
return new Promise(r => {
96-
serverProcess.stdout.on('data', d => {
96+
serverProcess?.stdout?.on('data', d => {
9797
const matches = d.toString('ascii').match(/Web UI available at (.+)/);
9898
if (matches !== null) {
9999
r(matches[1]);
@@ -102,6 +102,6 @@ async function launch() {
102102
});
103103
}
104104

105-
launch().then(async endpoint => {
106-
return runTestsInBrowser(argv.browser, endpoint);
105+
launchServer().then(async endpoint => {
106+
return runTestsInBrowser(optimist.argv.browser, endpoint);
107107
}, console.error);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"noImplicitAny": false,
5+
"removeComments": false,
6+
"preserveConstEnums": true,
7+
"target": "es2017",
8+
"strictNullChecks": true,
9+
"noUnusedParameters": false,
10+
"noUnusedLocals": true,
11+
"outDir": "out",
12+
"sourceMap": true,
13+
"lib": [
14+
"es2016",
15+
"dom"
16+
]
17+
},
18+
"exclude": [
19+
"node_modules"
20+
]
21+
}

test/integration/browser/yarn.lock

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@types/events@*":
6+
version "3.0.0"
7+
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
8+
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==
9+
10+
"@types/glob@*":
11+
version "7.1.1"
12+
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"
13+
integrity sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==
14+
dependencies:
15+
"@types/events" "*"
16+
"@types/minimatch" "*"
17+
"@types/node" "*"
18+
19+
"@types/minimatch@*":
20+
version "3.0.3"
21+
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
22+
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
23+
24+
"@types/mkdirp@0.5.1":
25+
version "0.5.1"
26+
resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.1.tgz#ea887cd024f691c1ca67cce20b7606b053e43b0f"
27+
integrity sha512-XA4vNO6GCBz8Smq0hqSRo4yRWMqr4FPQrWjhJt6nKskzly4/p87SfuJMFYGRyYb6jo2WNIQU2FDBsY5r1BibUA==
28+
dependencies:
29+
"@types/node" "*"
30+
31+
"@types/node@*":
32+
version "13.7.0"
33+
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4"
34+
integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==
35+
36+
"@types/node@^12.11.7":
37+
version "12.12.26"
38+
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.26.tgz#213e153babac0ed169d44a6d919501e68f59dea9"
39+
integrity sha512-UmUm94/QZvU5xLcUlNR8hA7Ac+fGpO1EG/a8bcWVz0P0LqtxFmun9Y2bbtuckwGboWJIT70DoWq1r3hb56n3DA==
40+
41+
"@types/rimraf@2.0.2":
42+
version "2.0.2"
43+
resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-2.0.2.tgz#7f0fc3cf0ff0ad2a99bb723ae1764f30acaf8b6e"
44+
integrity sha512-Hm/bnWq0TCy7jmjeN5bKYij9vw5GrDFWME4IuxV08278NtU/VdGbzsBohcCUJ7+QMqmUq5hpRKB39HeQWJjztQ==
45+
dependencies:
46+
"@types/glob" "*"
47+
"@types/node" "*"
48+
49+
balanced-match@^1.0.0:
50+
version "1.0.0"
51+
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
52+
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
53+
54+
brace-expansion@^1.1.7:
55+
version "1.1.11"
56+
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
57+
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
58+
dependencies:
59+
balanced-match "^1.0.0"
60+
concat-map "0.0.1"
61+
62+
concat-map@0.0.1:
63+
version "0.0.1"
64+
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
65+
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
66+
67+
fs.realpath@^1.0.0:
68+
version "1.0.0"
69+
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
70+
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
71+
72+
glob@^7.1.3:
73+
version "7.1.6"
74+
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
75+
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
76+
dependencies:
77+
fs.realpath "^1.0.0"
78+
inflight "^1.0.4"
79+
inherits "2"
80+
minimatch "^3.0.4"
81+
once "^1.3.0"
82+
path-is-absolute "^1.0.0"
83+
84+
inflight@^1.0.4:
85+
version "1.0.6"
86+
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
87+
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
88+
dependencies:
89+
once "^1.3.0"
90+
wrappy "1"
91+
92+
inherits@2:
93+
version "2.0.4"
94+
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
95+
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
96+
97+
minimatch@^3.0.4:
98+
version "3.0.4"
99+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
100+
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
101+
dependencies:
102+
brace-expansion "^1.1.7"
103+
104+
once@^1.3.0:
105+
version "1.4.0"
106+
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
107+
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
108+
dependencies:
109+
wrappy "1"
110+
111+
os-tmpdir@~1.0.2:
112+
version "1.0.2"
113+
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
114+
integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=
115+
116+
path-is-absolute@^1.0.0:
117+
version "1.0.1"
118+
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
119+
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
120+
121+
rimraf@^2.6.1:
122+
version "2.7.1"
123+
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"
124+
integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==
125+
dependencies:
126+
glob "^7.1.3"
127+
128+
tmp@0.0.33:
129+
version "0.0.33"
130+
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
131+
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
132+
dependencies:
133+
os-tmpdir "~1.0.2"
134+
135+
typescript@3.7.5:
136+
version "3.7.5"
137+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
138+
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==
139+
140+
wrappy@1:
141+
version "1.0.2"
142+
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
143+
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

test/smoke/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# VS Code Smoke Test
22

3-
Make sure you are on **Node v10.x**.
3+
Make sure you are on **Node v12.x**.
44

55
### Run
66

0 commit comments

Comments
 (0)