Skip to content

Commit 9c518c1

Browse files
authoredOct 14, 2024··
fix(browser): fix default browser port (#6700)
1 parent fde5d50 commit 9c518c1

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed
 

‎packages/browser/src/node/plugin.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,11 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
331331
const api = resolveApiServerConfig(
332332
viteConfig.test?.browser || {},
333333
defaultBrowserPort,
334-
) || {
335-
port: defaultBrowserPort,
336-
}
334+
)
337335

338336
viteConfig.server = {
339337
...viteConfig.server,
338+
port: defaultBrowserPort,
340339
...api,
341340
middlewareMode: false,
342341
open: false,

‎test/browser/fixtures/server-url/vitest.config.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import basicSsl from '@vitejs/plugin-basic-ssl'
66
// test https by
77
// TEST_HTTPS=1 pnpm test-fixtures --root fixtures/server-url
88

9-
const provider = process.env.PROVIDER || 'webdriverio';
9+
const provider = process.env.PROVIDER || 'playwright';
1010
const browser = process.env.BROWSER || (provider === 'playwright' ? 'chromium' : 'chrome');
1111

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

2222
export default defineConfig({
2323
plugins: [
2424
!!process.env.TEST_HTTPS && basicSsl(),
2525
],
2626
test: {
2727
browser: {
28+
api: process.env.TEST_HTTPS ? 51122 : 51133,
2829
enabled: true,
2930
provider,
3031
name: browser,

‎test/browser/specs/server-url.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test('server-url http', async () => {
1010
root: './fixtures/server-url',
1111
})
1212
expect(stderr).toBe('')
13-
expect(stdout).toContain(`Browser runner started by ${provider} at http://localhost:5173/`)
13+
expect(stdout).toContain(`Browser runner started by ${provider} at http://localhost:51133/`)
1414
})
1515

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

0 commit comments

Comments
 (0)
Please sign in to comment.