网页
综合
更新时间 2026-06-02 14:42:50
Configuring Vitest | Vitest
自动蜘蛛
vitest.dev
正文约 2134 字
watchTriggerPatterns
dangerouslyIgnoreUnhandled...
disableConsoleIntercept
browser.testerHtmlPath
browser.detailsPanelPosition
browser.screenshotDirectory
browser.screenshotFailures
browser.dependencySourcemaps
browser.orchestratorScripts
browser.connectTimeout
browser.trackUnhandledErrors
browser.importMapMocks
If you are using Vite and have a vite.config file, Vitest will read it to match with the plugins and setup as your Vite app. If you want to have a different configuration for testing or your main app doesn't rely on Vite specifically, you could either:
When an explicit --config option is not provided, Vitest looks for vitest.config.{ts,mts,cts,js,mjs,cjs} first and vite.config.{ts,mts,cts,js,mjs,cjs} second in the project root. If no config file is found, Vitest will run without one.
To configure vitest itself, add test property in your Vite config. You'll also need to add a reference to Vitest types using a triple slash command at the top of your config file, if you are importing defineConfig from vite itself.
If you are not using vite, add defineConfig imported from vitest/config to your config file:
If you have a vite config already, you can add /// <reference types="vitest/config" /> to include the test types:
You can retrieve Vitest's default options to expand them if needed:
When using a separate vitest.config.js, you can also extend Vite's options from another config file if needed:
If your Vite config is defined as a function, you can define the config like this:
Since Vitest uses Vite config, you can also use any configuration option from Vite. For example, define to define global variables, or resolve.alias to define aliases - these options should be defined on the top level, not within a test property.
Vitest will prompt you to install certain dependencies if they are not already installed. You can disable this behavior by setting the VITEST_SKIP_INSTALL_CHECKS=1 environment variable.
Configuration options that are not supported inside a project config have icon next to them. This means they can only be set in the root Vitest config.
© 2026 VoidZero Inc. and Vitest contributors.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。