···107107108108::: info
109109Vitest 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.
110110+111111+Since Vitest 2.1.5, CLI no longer prints the Vite URL automcatically. You can press "b" to print the URL when running in watch mode.
110112:::
111113112114If 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.
+1-4
test/browser/specs/runner.test.ts
···11import { readFile } from 'node:fs/promises'
22import { beforeAll, describe, expect, onTestFailed, test } from 'vitest'
33-import { defaultBrowserPort } from 'vitest/config'
44-import { browser, provider, runBrowserTests } from './utils'
33+import { browser, runBrowserTests } from './utils'
5465describe('running browser tests', async () => {
76 let stderr: string
···2827 onTestFailed(() => {
2928 console.error(stderr)
3029 })
3131-3232- expect(stdout).toContain(`Browser runner started by ${provider} at http://localhost:${defaultBrowserPort}/`)
33303431 expect(browserResultJson.testResults).toHaveLength(19)
3532 expect(passedTests).toHaveLength(17)
+9-5
test/browser/specs/server-url.test.ts
···11import { afterEach, expect, test } from 'vitest'
22-import { provider, runBrowserTests } from './utils'
22+import { runBrowserTests } from './utils'
3344afterEach(() => {
55 delete process.env.TEST_HTTPS
66})
7788test('server-url http', async () => {
99- const { stdout, stderr } = await runBrowserTests({
99+ const { stderr, ctx } = await runBrowserTests({
1010 root: './fixtures/server-url',
1111+ watch: true, // otherwise the browser is closed before we can get the url
1112 })
1313+ const url = ctx?.projects[0].browser?.vite.resolvedUrls?.local[0]
1214 expect(stderr).toBe('')
1313- expect(stdout).toContain(`Browser runner started by ${provider} at http://localhost:51133/`)
1515+ expect(url).toBe('http://localhost:51133/')
1416})
15171618test('server-url https', async () => {
1719 process.env.TEST_HTTPS = '1'
1818- const { stdout, stderr } = await runBrowserTests({
2020+ const { stdout, stderr, ctx } = await runBrowserTests({
1921 root: './fixtures/server-url',
2222+ watch: true, // otherwise the browser is closed before we can get the url
2023 })
2124 expect(stderr).toBe('')
2222- expect(stdout).toContain(`Browser runner started by ${provider} at https://localhost:51122/`)
2525+ const url = ctx?.projects[0].browser?.vite.resolvedUrls?.local[0]
2626+ expect(url).toBe('https://localhost:51122/')
2327 expect(stdout).toContain('Test Files 1 passed')
2428})