Skip to content

Browser Mode improvements #7585

@sheremet-va

Description

@sheremet-va

Clear and concise description of the problem

We've identified several pain points with Browser Mode:

  1. Users have to manually add @vitest/browser/providers/... types to tsconfig manually.
  2. It is not possible to opt-out of certain features like locators or jest-dom; we want a more simple setup like Karma or Web Test Runner

Suggested solution

These are some possible proposals:

Support browser providers via an export:

import { webdriverio } from '@vitest/browser-webdriverio'
// or
import { playwright } from '@vitest/browser-playwright'

export default defineConfig({
  plugins: [
    webdriverio({ ...customOptions }),
    // or
    playwright({ ...customOptions }),
  ],
})

browser-webdriverio/browser-playwright packages would also augment Vite config types to allow WebdriverIO/Playwright options in instances and require specific browser names, so users don't need to augment TypeScript types manually.

These packages will also have playwright/webdriverio in dependencies, so users don't need to install them manually.

New option browser.apis:

export default defineConfig({
  test: {
    browser: {
      apis: ['expect.element', 'locators', 'jest-dom'],
    },
  },
})

Users can opt-out of certain APIs to avoid the overhead of loading them.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runnerp2-nice-to-haveNot breaking anything but nice to have (priority)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions