[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
vitest docs config environmentoptions.md
881 B


title: environmentOptions | Config #

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 #

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. :::