Skip to content

Support different retry configurations for browser mode vs jsdom #9179

@l0king-alt

Description

@l0king-alt

Clear and concise description of the problem

Currently, the retry option in vitest.config.ts applies globally to all test environments. It would be valuable to have different retry configurations for browser tests versus jsdom tests.

Use Case:

Browser tests (via Playwright/WebDriver) are often more prone to flakiness due to:

  • Timing issues with real DOM rendering
  • Network requests
  • Animation/transition delays
  • Browser-specific rendering differences

Meanwhile, jsdom tests are typically more stable and deterministic. Having the ability to retry browser tests while keeping jsdom tests strict would improve CI reliability without masking issues in unit tests.

Suggested solution

This would probably be the best and easiest option:

export default defineConfig({
  test: {
    retry: 0, // Default for jsdom
    browser: {
      provider: playwright(),
      enabled: true,
      retry: 1, // Specific to browser tests
      instances: [{ browser: 'chromium' }],
    },
  },
});

Alternative

An alternative setup could be an environment-specific retry:

export default defineConfig({
  test: {
    retry: {
      browser: 1,
      jsdom: 0,
    },
  },
});

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions