This documentation covers Vitest v4 (old version). For the latest version, see https://vitest.dev.

Skip to content

environmentOptions ​

  • Type: Record<'jsdom' | 'happyDOM' | string, unknown>
  • Default: {}

These options are passed to the setup method of the current environment. By default, you can configure options only for jsdom and happyDOM when you use them as your test environment.

Example ​

vitest.config.js
js
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    environmentOptions: {
      jsdom: {
        url: 'http://localhost:3000',
      },
      happyDOM: {
        width: 300,
        height: 400,
      },
    },
  },
})

WARNING

Options are scoped to their environment. For example, put jsdom options under the jsdom key and happy-dom options under the happyDOM key. This lets you mix multiple environments within the same project.