Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(browser): fix default browser port #6700

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,11 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
const api = resolveApiServerConfig(
viteConfig.test?.browser || {},
defaultBrowserPort,
) || {
port: defaultBrowserPort,
}
)

viteConfig.server = {
...viteConfig.server,
port: defaultBrowserPort,
...api,
middlewareMode: false,
open: false,
Expand Down
5 changes: 3 additions & 2 deletions test/browser/fixtures/server-url/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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 provider = process.env.PROVIDER || 'playwright';
const browser = process.env.BROWSER || (provider === 'playwright' ? 'chromium' : 'chrome');

// ignore https errors due to self-signed certificate from plugin-basic-ssl
Expand All @@ -17,14 +17,15 @@ const providerOptions = (function () {
case 'playwright': return { page: { ignoreHTTPSErrors: true } }
case 'webdriverio': return { strictSSL: false, capabilities: { acceptInsecureCerts: true } }
}
})()
})() as any

export default defineConfig({
plugins: [
!!process.env.TEST_HTTPS && basicSsl(),
],
test: {
browser: {
api: process.env.TEST_HTTPS ? 51122 : 51133,
enabled: true,
provider,
name: browser,
Expand Down
4 changes: 2 additions & 2 deletions test/browser/specs/server-url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('server-url http', async () => {
root: './fixtures/server-url',
})
expect(stderr).toBe('')
expect(stdout).toContain(`Browser runner started by ${provider} at http://localhost:5173/`)
expect(stdout).toContain(`Browser runner started by ${provider} at http://localhost:51133/`)
})

test('server-url https', async () => {
Expand All @@ -19,6 +19,6 @@ test('server-url https', async () => {
root: './fixtures/server-url',
})
expect(stderr).toBe('')
expect(stdout).toContain(`Browser runner started by ${provider} at https://localhost:5173/`)
expect(stdout).toContain(`Browser runner started by ${provider} at https://localhost:51122/`)
expect(stdout).toContain('Test Files 1 passed')
})