Specifies an Object, or an Array of Object,
which defines aliases used to replace values in import or require statements.
Will be merged with the default aliases inside resolve.alias.
Allow tests and suites that are marked as only
Directory path for storing attachments created by context.annotate
OptionalbailOptionalbaseOptionalbenchmarkModify default Chai config. Vitest uses Chai for expect and assert matches.
https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
Runs tests that are affected by the changes in the repository, or between specified branch or commit hash Requires initialized git repository
ExperimentalclearDelete all Vitest caches, including experimental.fsModuleCache.
Will call .mockClear() on all spies before each test
Override vite config's clearScreen from cli
OptionalcliOptionalcolorbenchmark.compare option exposed at the top level for cli
OptionalconfigIndicates if CSS files should be processed.
When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
Ignore any unhandled errors that occur
Handling for dependencies inlining or externalizing
OptionaldiffBase directory to scan for the test files
By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc... This is also required for console log preview on Vitest UI. However, disabling such interception might help when you want to debug a code with normal synchronous terminal console logging.
This option has no effect on browser pool since Vitest preserves original logging on browser devtools.
Use happy-dom
OptionaldumpCustom environment variables assigned to process.env before running tests.
Running environment
Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
If used unsupported string, will try to load the package vitest-environment-${env}
Environment options.
Exclude globs for test files
Pass additional arguments to node process when spawning the worker.
See Command-line API | Node.js for more information.
Set to process.execArgv to pass all arguments of the current process.
Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
Show full diff when snapshot fails instead of a patch.
Configuration options for expect() matches.
Optionalpoll?: { interval?: number; timeout?: number }Default options for expect.poll()
Optionalinterval?: numberPolling interval in milliseconds
Optionaltimeout?: numberTimeout in milliseconds
OptionalrequireAssertions?: booleanThrow an error if tests don't have any expect() assertions.
ExperimentalexperimentalExperimental features
OptionalfsModuleCache?: booleanEnable caching of modules on the file system between reruns.
OptionalfsModuleCachePath?: stringPath relative to the root of the project where the fs module cache will be stored.
OptionalopenTelemetry?: { enabled: boolean; sdkPath?: string }OptionalprintImportBreakdown?: booleanShow imports (top 10) that take a long time.
Enabling this will also show a breakdown by default in UI, but you can always press a button to toggle it.
Options for @sinon/fake-timers
OptionalfiltersGlob pattern of file paths that will trigger the whole suite rerun
Useful if you are testing calling CLI commands
Register apis globally
Path to global setup files
Hide logs for skipped tests
Default timeout of a hook in milliseconds
A list of glob patterns that match your test files.
Include globs for in-source test files
Include "location" property inside the test definition
Debug tests by opening node:inspector in worker / child process.
Provides similar experience as --inspect Node CLI argument.
Requires fileParallelism: false.
Debug tests by opening node:inspector in worker / child process and wait for debugger to connect.
Provides similar experience as --inspect-brk Node CLI argument.
Requires fileParallelism: false.
Inspector options. If --inspect or --inspect-brk is enabled, these options will be passed to the inspector.
Optionalenabled?: booleanEnable inspector
Optionalhost?: stringHost to run inspector on
Optionalport?: numberPort to run inspector on
OptionalwaitForDebugger?: booleanWait for debugger to connect before running tests
Run tests in an isolated environment. This option has no effect on vmThreads pool.
Disabling this option improves performance if your code doesn't rely on side effects.
Show heap usage after each test. Useful for debugging memory leaks.
A number of tests that are allowed to run at the same time marked with test.concurrent.
Maximum number or percentage of workers to run tests in.
Directory of blob reports to merge
Will call .mockReset() on all spies before each test
Overrides Vite mode
Custom handler for console.log in tests.
Return false to ignore the log.
Enable stack trace filtering. If absent, all stack trace frames will be shown.
Return false to omit the frame.
A callback that can return false to ignore an unhandled error
Open UI automatically.
Write test results to a file when the --reporter=jsonor--reporter=junit` option is also specified.
Also definable individually per reporter by using an object instead.
benchmark.outputJson option exposed at the top level for cli
Pass with no tests
OptionalpoolAlways print console stack traces.
Options for projects
Define variables that will be returned from inject in the test environment.
OptionalrelatedWill call .mockRestore() on all spies before each test
Retry the test specific number of times if it fails.
Project root
OptionalrunnerOptionalshardSilent mode
Use 'passed-only' to see logs from failing tests only.
The number of milliseconds after which a test is considered slow and reported as such in the results.
OptionalsnapshotFormat options for snapshot testing.
Paths to snapshot serializer modules.
Do not run tests when Vitest starts.
Vitest will only run tests if it's called programmatically or the test file changes.
If CLI file filters are passed, standalone mode is ignored.
Default timeout to wait for close when Vitest shuts down, in milliseconds
OptionaltestDefault timeout of a test in milliseconds
Enable Vitest UI
Base url for the UI
Will restore all env stubs to their original values before each test
Will restore all global stubs to their original values before each test
Update snapshot
OptionalvmWatch mode
Pattern configuration to rerun only the tests that are affected by the changes of specific files in the repository.
Construct a type with the properties of T except for those in type K.