Skip to content

Add a configuration option to chose the Vitest project(s)Β #683

@severo

Description

@severo

Clear and concise description of the problem

I have two Vitest projects:

  • one to test with node,
  • another one to test with browsers (firefox and chromium), using the Vitest "browser" mode.

But running the tests in debug mode in VSCode gives me this error:

VSCode can only debug tests running in the "chromium" browser. url.test.ts [browser (firefox)] runs in firefox instead.

Suggested solution

Add an option to use only one project (or a selection of projects)

Alternative

Manually comment Firefox (or the whole "browsers" project) in the Vitest configuration file:

            instances: [
              { browser: 'chromium' },
              // { browser: 'firefox' },
            ]

Additional context

For reference, this is my vitest.config.js file:

import { playwright } from '@vitest/browser-playwright'
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    projects: [
      {
        test: {
          name: 'node',
          environment: 'node',
        },
      },
      {
        test: {
          name: 'browser',
          browser: {
            enabled: true,
            provider: playwright(),
            headless: true,
            screenshotFailures: false,
            // https://vitest.dev/guide/browser/playwright
            instances: [
              { browser: 'chromium' },
              { browser: 'firefox' },
            ],
          },
        },
      },
    ],
  },
})

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions