Skip to content

Commit

Permalink
fix(browser): fix default browser port (#6700)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Oct 14, 2024
1 parent fde5d50 commit 9c518c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
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')
})

0 comments on commit 9c518c1

Please sign in to comment.