diff --git a/test/smoke/src/vscode/code.ts b/test/smoke/src/vscode/code.ts index 364e44acf3c..8a7ffc3d7b1 100644 --- a/test/smoke/src/vscode/code.ts +++ b/test/smoke/src/vscode/code.ts @@ -173,7 +173,7 @@ export async function spawn(options: SpawnOptions): Promise { let connectDriver: typeof connectElectronDriver; if (options.web) { - launch(args); + await launch(args); connectDriver = connectPuppeteerDriver.bind(connectPuppeteerDriver, !!options.headless); } else { const spawnOptions: cp.SpawnOptions = { env }; diff --git a/test/smoke/src/vscode/puppeteerDriver.ts b/test/smoke/src/vscode/puppeteerDriver.ts index 0397c313436..85621a74cbf 100644 --- a/test/smoke/src/vscode/puppeteerDriver.ts +++ b/test/smoke/src/vscode/puppeteerDriver.ts @@ -4,6 +4,9 @@ *--------------------------------------------------------------------------------------------*/ import * as puppeteer from 'puppeteer'; +import { ChildProcess, spawn } from 'child_process'; +import { join } from 'path'; +import { Readable } from 'stream'; const width = 1200; const height = 800; @@ -177,10 +180,23 @@ function timeout(ms: number): Promise { // function runInDriver(call: string, args: (string | boolean)[]): Promise {} let args; +let server: ChildProcess; +let endpoint: string | undefined; -export function launch(_args): void { +export async function launch(_args): Promise { args = _args; - // TODO: Move puppeteer launch here + console.log('launch args', args); + + // TODO: --web-user-data-dir (tmpdir) + server = spawn(join(args[0], '/resources/server/web.sh'), ['--driver', 'web']); + endpoint = await new Promise(r => { + server.stdout.on('data', d => { + const matches = d.toString('ascii').match(/Web UI available at (.+)/); + if (matches !== null) { + r(matches[1]); + } + }); + }); } export function connect(headless: boolean, outPath: string, handle: string): Promise<{ client: IDisposable, driver: IDriver }> { @@ -194,9 +210,14 @@ export function connect(headless: boolean, outPath: string, handle: string): Pro }); const page = (await browser.pages())[0]; await page.setViewport({ width, height }); - await page.goto(`http://127.0.0.1:9888?folder=${args[1]}`); + const endpointSplit = endpoint!.split('#'); + await page.goto(`${endpointSplit[0]}?folder=${args[1]}#${endpointSplit[1]}`); const result = { - client: { dispose: () => { } }, + client: { + dispose: () => { + server.kill(); + } + }, driver: buildDriver(browser, page) }; c(result);