KC's Workspace
    Preparing search index...
    interface BrowserConfigOptions {
        api?: number | ApiConfig;
        commands?: Record<string, BrowserCommand<any, any>>;
        connectTimeout?: number;
        enabled?: boolean;
        expect?: { toMatchScreenshot?: undefined };
        fileParallelism?: boolean;
        headless?: boolean;
        instances?: BrowserInstanceOption[];
        isolate?: boolean;
        locators?: { testIdAttribute?: string };
        orchestratorScripts?: BrowserScript[];
        provider?: BrowserProviderOption<object>;
        screenshotDirectory?: string;
        screenshotFailures?: boolean;
        testerHtmlPath?: string;
        trace?:
            | BrowserTraceViewMode
            | {
                mode: BrowserTraceViewMode;
                screenshots?: boolean;
                snapshots?: boolean;
                tracesDir?: string;
            };
        trackUnhandledErrors?: boolean;
        ui?: boolean;
        viewport?: { height: number; width: number };
    }

    Hierarchy (View Summary)

    Index

    Properties

    api?: number | ApiConfig

    Serve API options.

    The default port is 63315.

    commands?: Record<string, BrowserCommand<any, any>>

    Commands that will be executed on the server via the browser import("vitest/browser").commands API.

    connectTimeout?: number

    Timeout for connecting to the browser

    30000
    
    enabled?: boolean

    if running tests in the browser should be the default

    false
    
    expect?: { toMatchScreenshot?: undefined }
    fileParallelism?: boolean

    Run test files in parallel if provider supports this option This option only has effect in headless mode (enabled in CI by default)

    // Same as "test.fileParallelism"
    

    use top-level fileParallelism instead

    headless?: boolean

    enable headless mode

    process.env.CI
    
    instances?: BrowserInstanceOption[]

    Configurations for different browser setups

    isolate?: boolean

    Isolate test environment after each test

    true
    

    use top-level isolate instead

    locators?: { testIdAttribute?: string }

    Locator options

    Type Declaration

    • OptionaltestIdAttribute?: string

      Attribute used to locate elements by test id

      'data-testid'
      
    orchestratorScripts?: BrowserScript[]

    Scripts injected into the main window.

    provider?: BrowserProviderOption<object>

    Browser provider

    import { playwright } from '@vitest/browser-playwright'
    export default defineConfig({
    test: {
    browser: {
    provider: playwright(),
    },
    },
    })
    screenshotDirectory?: string

    Directory where screenshots will be saved when page.screenshot() is called If not set, all screenshots are saved to screenshots directory in the same folder as the test file. If this is set, it will be resolved relative to the project root.

    __screenshots__
    
    screenshotFailures?: boolean

    Should Vitest take screenshots if the test fails

    !browser.ui
    
    testerHtmlPath?: string

    Path to the index.html file that will be used to run tests.

    trace?:
        | BrowserTraceViewMode
        | {
            mode: BrowserTraceViewMode;
            screenshots?: boolean;
            snapshots?: boolean;
            tracesDir?: string;
        }

    Generate traces that can be viewed on https://trace.playwright.dev/

    This option is supported only by playwright provider.

    Type Declaration

    • BrowserTraceViewMode
    • {
          mode: BrowserTraceViewMode;
          screenshots?: boolean;
          snapshots?: boolean;
          tracesDir?: string;
      }
      • mode: BrowserTraceViewMode
      • Optionalscreenshots?: boolean

        Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview.

        true
        
      • Optionalsnapshots?: boolean

        If this option is true tracing will

        • capture DOM snapshot on every action
        • record network activity
        true
        
      • OptionaltracesDir?: string

        The directory where all traces will be stored. By default, Vitest stores all traces in __traces__ folder close to the test file.

    trackUnhandledErrors?: boolean

    Enables tracking uncaught errors and exceptions so they can be reported by Vitest.

    If you need to hide certain errors, it is recommended to use onUnhandledError option instead.

    Disabling this will completely remove all Vitest error handlers, which can help debugging with the "Pause on exceptions" checkbox turned on.

    true
    
    ui?: boolean

    Show Vitest UI

    !process.env.CI
    
    viewport?: { height: number; width: number }

    Default viewport size

    Type Declaration

    • height: number

      Height of the viewport

      896
      
    • width: number

      Width of the viewport

      414