Skip to content

browser.instances ​

  • Type: BrowserConfig
  • Default: []

Defines multiple browser setups. Every config has to have at least a browser field.

You can specify most of the project options (not marked with a icon) and some of the browser options like browser.testerHtmlPath.

WARNING

Every browser config inherits options from the root config:

vitest.config.ts
ts
export default defineConfig({
  test: {
    setupFile: ['./root-setup-file.js'],
    browser: {
      enabled: true,
      testerHtmlPath: './custom-path.html',
      instances: [
        {
          // will have both setup files: "root" and "browser"
          setupFile: ['./browser-setup-file.js'],
          // implicitly has "testerHtmlPath" from the root config
          // testerHtmlPath: './custom-path.html',
        },
      ],
    },
  },
})

For more examples, refer to the "Multiple Setups" guide.

The globalSetup files of the config that defines instances run once for all of them, not once per instance, and receive the project of that config. Values they provide with project.provide are available in every instance. Global setup files defined in an instance run only for that instance.

List of available browser options:

Under the hood, Vitest transforms these instances into separate test projects sharing a single Vite server for better caching performance.