Skip to content

Commit

Permalink
test(browser): unskipped https test for browser (#5290)
Browse files Browse the repository at this point in the history
  • Loading branch information
saitonakamura committed Feb 26, 2024
1 parent 5bb8b38 commit de8cf2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 11 additions & 0 deletions test/browser/fixtures/server-url/vitest.config.ts
Expand Up @@ -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(),
Expand All @@ -18,6 +28,7 @@ export default defineConfig({
enabled: true,
provider,
name: browser,
providerOptions,
},
},
// separate cacheDir from test/browser/vite.config.ts
Expand Down
7 changes: 3 additions & 4 deletions test/browser/specs/server-url.test.mjs
Expand Up @@ -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',
},
Expand Down

0 comments on commit de8cf2d

Please sign in to comment.