Browser Mode Setup in Vitest

From the Vitest cheat sheet ยท Browser Mode ยท verified Nov 2026

Browser Mode Setup

Install a provider and configure browser instances, headless mode, and trace view

typescript
// npm i -D @vitest/browser-playwright   (or: npx vitest init browser)
import { defineConfig } from 'vitest/config'
import { playwright } from '@vitest/browser-playwright'

export default defineConfig({
  test: {
    browser: {
      enabled: true,
      provider: playwright(),
      instances: [{ browser: 'chromium' }],
    },
  },
})
๐Ÿ“Œ Tests run in a real browser, with the same test, expect and vi APIs
๐Ÿ’ก Start with Playwright: it supports parallel browser sessions
โš ๏ธ 5.1 moved the browser port to 23315; set api.port if needed
๐Ÿ” 5.1 keeps a step-by-step trace for failing tests by default
browser-modeplaywrightsetup

Continue with Vitest

Save the full cheat sheet or work through every related task.

More Vitest tasks

Back to the full Vitest cheat sheet