From b4fdce32e276d646faae120a2f908c176ddf7dae Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 13 Oct 2024 14:41:02 +0900 Subject: [PATCH 1/2] fix(browser): fix default browser port --- packages/browser/src/node/plugin.ts | 5 ++--- test/browser/specs/server-url.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/browser/src/node/plugin.ts b/packages/browser/src/node/plugin.ts index b21daebb3399..7a7d5f37767c 100644 --- a/packages/browser/src/node/plugin.ts +++ b/packages/browser/src/node/plugin.ts @@ -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, diff --git a/test/browser/specs/server-url.test.ts b/test/browser/specs/server-url.test.ts index 46010ee348bc..a3c8f73bd4b4 100644 --- a/test/browser/specs/server-url.test.ts +++ b/test/browser/specs/server-url.test.ts @@ -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:63315/`) }) test('server-url https', async () => { @@ -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:63315/`) expect(stdout).toContain('Test Files 1 passed') }) From a080ee393da61364f4d4e6ac3bf4c583d69b7d16 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 13 Oct 2024 14:48:47 +0900 Subject: [PATCH 2/2] test: cleanup --- test/browser/fixtures/server-url/vitest.config.ts | 5 +++-- test/browser/specs/server-url.test.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/browser/fixtures/server-url/vitest.config.ts b/test/browser/fixtures/server-url/vitest.config.ts index 20cada4d3c5c..25eb22e5965b 100644 --- a/test/browser/fixtures/server-url/vitest.config.ts +++ b/test/browser/fixtures/server-url/vitest.config.ts @@ -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 @@ -17,7 +17,7 @@ const providerOptions = (function () { case 'playwright': return { page: { ignoreHTTPSErrors: true } } case 'webdriverio': return { strictSSL: false, capabilities: { acceptInsecureCerts: true } } } -})() +})() as any export default defineConfig({ plugins: [ @@ -25,6 +25,7 @@ export default defineConfig({ ], test: { browser: { + api: process.env.TEST_HTTPS ? 51122 : 51133, enabled: true, provider, name: browser, diff --git a/test/browser/specs/server-url.test.ts b/test/browser/specs/server-url.test.ts index a3c8f73bd4b4..84f544cf5bd7 100644 --- a/test/browser/specs/server-url.test.ts +++ b/test/browser/specs/server-url.test.ts @@ -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:63315/`) + expect(stdout).toContain(`Browser runner started by ${provider} at http://localhost:51133/`) }) test('server-url https', async () => { @@ -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:63315/`) + expect(stdout).toContain(`Browser runner started by ${provider} at https://localhost:51122/`) expect(stdout).toContain('Test Files 1 passed') })