Skip to content

Commit

Permalink
docs: mention that the browser mode uses 63315 port (#6691)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Oct 11, 2024
1 parent d131fd6 commit 502ecbf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ Run every test in a separate iframe.
- **Default:** `63315`
- **CLI:** `--browser.api=63315`, `--browser.api.port=1234, --browser.api.host=example.com`

Configure options for Vite server that serves code in the browser. Does not affect [`test.api`](#api) option.
Configure options for Vite server that serves code in the browser. Does not affect [`test.api`](#api) option. By default, Vitest assigns port `63315` to avoid conflicts with the development server, allowing you to run both in parallel.

#### browser.provider

Expand Down
4 changes: 4 additions & 0 deletions docs/guide/browser/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export default defineConfig({
})
```

::: info
Vitest assigns port `63315` to avoid conflicts with the development server, allowing you to run both in parallel. You can change that with the [`browser.api`](/config/#browser-api) option.
:::

If you have not used Vite before, make sure you have your framework's plugin installed and specified in the config. Some frameworks might require extra configuration to work - check their Vite related documentation to be sure.

::: code-group
Expand Down
8 changes: 3 additions & 5 deletions packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,17 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
viteConfig.esbuild.legalComments = 'inline'
}

const server = resolveApiServerConfig(
const api = resolveApiServerConfig(
viteConfig.test?.browser || {},
defaultBrowserPort,
) || {
port: defaultBrowserPort,
}

// browser never runs in middleware mode
server.middlewareMode = false

viteConfig.server = {
...viteConfig.server,
...server,
...api,
middlewareMode: false,
open: false,
}
viteConfig.server.fs ??= {}
Expand Down

0 comments on commit 502ecbf

Please sign in to comment.