From 1257c8a53658d7781843c50be23ec417843abb4e Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 5 Apr 2023 20:23:59 +0200 Subject: [PATCH 1/3] configure context before opening page --- src/index.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7306240..137696b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -183,9 +183,7 @@ export async function runTests(options: Options & { extensionTestsPath: string } const endpoint = `http://${host}:${port}`; - console.log(`Opening browser on ${endpoint}...`); - const context = await openBrowser(endpoint, options); - if (context) { + const configContext = async (context: playwright.BrowserContext) => { context.once('close', () => server.close()); type Severity = 'error' | 'warning' | 'info'; @@ -215,7 +213,11 @@ export async function runTests(options: Options & { extensionTestsPath: string } e(new Error('Test failed')); } }); - } else { + + } + console.log(`Opening browser on ${endpoint}...`); + const context = await openBrowser(endpoint, options, configContext); + if (!context) { server.close(); e(new Error('Can not run test as opening of browser failed.')); } @@ -253,9 +255,12 @@ export async function open(options: Options): Promise { const server = await runServer(host, port, config); const endpoint = `http://${host}:${port}`; - const context = await openBrowser(endpoint, options); - context?.once('close', () => server.close()); + const configContext = async (context: playwright.BrowserContext) => { + context.once('close', () => server.close()); + }; + + const context = await openBrowser(endpoint, options, configContext); return { dispose: () => { server.close(); @@ -265,7 +270,7 @@ export async function open(options: Options): Promise { } -async function openBrowser(endpoint: string, options: Options): Promise { +async function openBrowser(endpoint: string, options: Options, configureContext: (context: playwright.BrowserContext) => Promise): Promise { if (options.browserType === 'none') { return undefined; } @@ -293,6 +298,8 @@ async function openBrowser(endpoint: string, options: Options): Promise { From 6d4145d916ca746f9af5fe1bc0f8c15da965d55f Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 5 Apr 2023 20:26:46 +0200 Subject: [PATCH 2/3] use node 16 for github-ci --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 33a3584..5f37b7c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: - name: Install Node.js uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x - name: Install root project dependencies run: yarn - name: Install extensions dependencies From 9c0d00a4fd8e3181e3f556626ba980fe48031d09 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 5 Apr 2023 22:21:24 +0200 Subject: [PATCH 3/3] prepare 0.0.39 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d9bbd1b..c1fc8b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vscode/test-web", - "version": "0.0.38", + "version": "0.0.39", "scripts": { "install-extensions": "yarn --cwd=fs-provider && yarn --cwd=sample", "compile": "tsc -p ./ && yarn compile-fs-provider",