From de8cf2d5ba05debfd40e1846800b1f15eb930165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20=E3=82=B5=E3=82=A4=E3=83=88=E3=83=BC=20=E4=B8=AD?= =?UTF-8?q?=E6=9D=91=20Bashurov?= Date: Mon, 26 Feb 2024 05:07:23 +0200 Subject: [PATCH] test(browser): unskipped https test for browser (#5290) --- test/browser/fixtures/server-url/vitest.config.ts | 11 +++++++++++ test/browser/specs/server-url.test.mjs | 7 +++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/browser/fixtures/server-url/vitest.config.ts b/test/browser/fixtures/server-url/vitest.config.ts index 201a7553d3e6..20cada4d3c5c 100644 --- a/test/browser/fixtures/server-url/vitest.config.ts +++ b/test/browser/fixtures/server-url/vitest.config.ts @@ -9,6 +9,16 @@ import basicSsl from '@vitejs/plugin-basic-ssl' const provider = process.env.PROVIDER || 'webdriverio'; const browser = process.env.BROWSER || (provider === 'playwright' ? 'chromium' : 'chrome'); +// ignore https errors due to self-signed certificate from plugin-basic-ssl +// https://playwright.dev/docs/api/class-browser#browser-new-context-option-ignore-https-errors +// https://webdriver.io/docs/configuration/#strictssl and acceptInsecureCerts in https://webdriver.io/docs/api/browser/#properties +const providerOptions = (function () { + switch (provider) { + case 'playwright': return { page: { ignoreHTTPSErrors: true } } + case 'webdriverio': return { strictSSL: false, capabilities: { acceptInsecureCerts: true } } + } +})() + export default defineConfig({ plugins: [ !!process.env.TEST_HTTPS && basicSsl(), @@ -18,6 +28,7 @@ export default defineConfig({ enabled: true, provider, name: browser, + providerOptions, }, }, // separate cacheDir from test/browser/vite.config.ts diff --git a/test/browser/specs/server-url.test.mjs b/test/browser/specs/server-url.test.mjs index d6413b6bfe2e..9060edf41439 100644 --- a/test/browser/specs/server-url.test.mjs +++ b/test/browser/specs/server-url.test.mjs @@ -13,11 +13,10 @@ test('server-url http', async () => { assert.match(result.stdout, /Test Files {2}1 passed/) }) -// this test is skipped since browser warns self-signed https and it requires manual interaction. -// you can toggle "skip" to verify it locally. -test('server-url https', { skip: true }, async () => { - const result = await execa('npx', ['vitest', 'run', '--root=./fixtures/server-url'], { +test('server-url https', async () => { + const result = await execa('npx', ['vitest', 'run', '--root=./fixtures/server-url', '--browser.headless'], { env: { + CI: '1', NO_COLOR: '1', TEST_HTTPS: '1', },