-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(browser): fix browser testing url for https (#4855)
- Loading branch information
Showing
9 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { expect, test } from "vitest"; | ||
|
||
test("basic", () => { | ||
expect(1).toBe(1); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import path from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
import { defineConfig } from 'vitest/config' | ||
import basicSsl from '@vitejs/plugin-basic-ssl' | ||
|
||
// test https by | ||
// TEST_HTTPS=1 pnpm test-fixtures --root fixtures/server-url | ||
|
||
const provider = process.env.PROVIDER || 'webdriverio'; | ||
const browser = process.env.BROWSER || (provider === 'playwright' ? 'chromium' : 'chrome'); | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
!!process.env.TEST_HTTPS && basicSsl(), | ||
], | ||
test: { | ||
browser: { | ||
enabled: true, | ||
provider, | ||
name: browser, | ||
}, | ||
}, | ||
// separate cacheDir from test/browser/vite.config.ts | ||
// to prevent pre-bundling related flakiness on Webkit | ||
cacheDir: path.join(path.dirname(fileURLToPath(import.meta.url)), "node_modules/.vite") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import assert from 'node:assert' | ||
import test from 'node:test' | ||
import { execa } from 'execa' | ||
|
||
test('server-url http', async () => { | ||
const result = await execa('npx', ['vitest', 'run', '--root=./fixtures/server-url', '--browser.headless'], { | ||
env: { | ||
CI: '1', | ||
NO_COLOR: '1', | ||
}, | ||
}) | ||
assert.match(result.stdout, /Browser runner started at http:\/\/localhost:5173\//) | ||
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'], { | ||
env: { | ||
NO_COLOR: '1', | ||
TEST_HTTPS: '1', | ||
}, | ||
}) | ||
assert.match(result.stdout, /Browser runner started at https:\/\/localhost:5173\//) | ||
assert.match(result.stdout, /Test Files {2}1 passed/) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters