Configure options below — the preview updates in real time.
Control which files Vitest includes, excludes, and where it looks for tests.
Glob patterns specifying which test files to execute.
Glob patterns specifying which files to exclude from tests.
Glob patterns to detect files containing in-source tests (e.g. if (import.meta.vitest) blocks).
The base directory for scanning test files. Defaults to the project root.
The root directory of the Vitest project.
Label for the specific project or workspace config (shows in console output).
Configure the test execution environment and global setup files.
The environment in which tests will run.
Files executed before every test file to configure the test runner or test environment.
Files run once before all test suites start, useful for spinning up global databases or servers.
Match specific file globs to different environments as key-value pairs (glob: environment).
Configure worker pools, parallelism, and isolation settings.
Defines the worker pool architecture used to run isolated test environments.
Maximum number of workers to run concurrently. Accepts a number or a percentage string (e.g. 50%).
Minimum number of workers to keep alive.
Control test timeouts, retries, bail behavior, and execution order.
Default timeout for an individual test case in milliseconds.
Default timeout for test hooks (beforeAll, beforeEach, etc.) in milliseconds.
Default timeout to tear down Vitest environments safely in milliseconds.
Stop test execution immediately after the specified number of failed tests. 0 means no bail.
Number of times to automatically retry a failed test.
The number of milliseconds after which a test or suite is considered slow and reported as such.
Maximum number of tests and hooks that can run at the same time when using test.concurrent or describe.concurrent.
Seed for random shuffle when shuffle is enabled. Defaults to Date.now().
Controls how hooks are executed.
Controls how setup files are executed.
Configure test reporters and output behavior.
Custom reporters to format test outputs.
File path where test reports should be dumped (e.g. ./test-results.json).
Configure code coverage collection, providers, thresholds, and reporting.
The engine generating coverage.
File globs to strictly include in coverage.
File globs to ignore in coverage.
Allowed file extensions for coverage (e.g. .js, .ts).
Directory for dumping coverage outputs.
Coverage report formats to generate.
Concurrency limit for parsing coverage output. Defaults to min(20, available CPU cores).
Import path if using a custom coverage provider.
Minimum line coverage percentage.
Minimum function coverage percentage.
Minimum branch coverage percentage.
Minimum statement coverage percentage.
Configure watch mode, UI dashboard, and debugging options.
Glob patterns that trigger a test re-run when matching files change.
If these config files change, all tests rerun regardless of caching.
Base route for the Vitest UI.
Configure automatic mock clearing, timer faking, and state isolation.
Milliseconds of real time delta for advancing fake timers.
Maximum number of timer loops to prevent infinite loops.
Configure assertion behavior, chai settings, and snapshot formatting.
Interval in milliseconds for polling expect matchers.
Timeout in milliseconds for polling expect matchers.
Threshold length for truncating assertion values in output.
Number of indentation spaces for snapshot output.
Maximum depth of serialized snapshot objects.
Maximum width of serialized snapshot arrays.
Configure type checking, CSS handling, and dependency resolution.
The type checker to use.
File globs to include in type checking.
File globs to exclude from type checking.
Path to the tsconfig.json file.
RegExp patterns for files that should return actual CSS and be processed by the Vite pipeline.
RegExp patterns for files that will return an empty CSS file.
Vite-style alias mapping, merged with base resolve.alias. Map alias keys to paths.
Set environment variables for tests and configure the cache.
Map of explicit environment variables (process.env.*) to inject during tests.
Overrides Vite mode during test execution.
Configure running tests directly inside a real browser.
The driver for the browser.
Path to output failed browser captures.
Width of the browser viewport in pixels.
Height of the browser viewport in pixels.
Custom path to inject browser tests.
1import { defineConfig } from "vitest/config";23export default defineConfig({4 test: {},5});