OptionalaliasOptionalallowAllow tests and suites that are marked as only
OptionalapiServe API options.
When set to true, the default port is 51204.
OptionalattachmentsDirectory path for storing attachments created by context.annotate
OptionalbailStop test execution when given number of tests have failed.
OptionalbenchmarkBenchmark options.
Optionalbrowseroptions for test in a browser environment
OptionalcacheOptions for configuring cache policy.
OptionalchaiModify default Chai config. Vitest uses Chai for expect and assert matches.
https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
OptionalchangedRuns tests that are affected by the changes in the repository, or between specified branch or commit hash Requires initialized git repository
Optional ExperimentalclearDelete all Vitest caches, including experimental.fsModuleCache.
OptionalclearWill call .mockClear() on all spies before each test
OptionalclearOverride vite config's clearScreen from cli
OptionalcliAdditional exclude patterns
Optionalcomparebenchmark.compare option exposed at the top level for cli
OptionalconfigPath to the config file.
Default resolving to vitest.config.*, vite.config.*
Setting to false will disable config resolving.
OptionalcoverageCoverage options
OptionalcssIndicates if CSS files should be processed.
When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
OptionaldangerouslyIgnore any unhandled errors that occur
OptionaldepsHandling for dependencies inlining or externalizing
OptionaldetectDetect asynchronous resources leaking from the test file.
OptionaldiffPath to a module which has a default export of diff config.
OptionaldirBase directory to scan for the test files
OptionaldisableBy 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.
OptionaldomUse happy-dom
OptionalenvCustom environment variables assigned to process.env before running tests.
OptionalenvironmentRunning environment
Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
If used unsupported string, will try to load the package vitest-environment-${env}
OptionalenvironmentEnvironment options.
OptionalexcludeExclude globs for test files
OptionalexecPass 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
OptionalexpandShow full diff when snapshot fails instead of a patch.
OptionalexpectConfiguration 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.
Optional 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.
OptionalimportDurations?: {Configure import duration collection and display.
The limit option controls how many imports to collect and display.
The print option controls CLI terminal output.
UI can always toggle the breakdown display regardless of print setting.
OptionalfailOnDanger?: booleanFail the test run if any import exceeds the danger threshold.
When failing, the breakdown is always printed regardless of print setting.
Optionallimit?: numberMaximum number of imports to collect and display.
Optionalprint?: boolean | "on-warn"When to print import breakdown to CLI terminal after tests finish.
true: Always printfalse: Never print (default)'on-warn': Print only when any import exceeds the warn thresholdOptionalthresholds?: { danger?: number; warn?: number }Duration thresholds in milliseconds for coloring and warnings.
Optionaldanger?: numberDanger threshold - imports exceeding this are shown in red.
Optionalwarn?: numberWarning threshold - imports exceeding this are shown in yellow/orange.
OptionalnodeLoader?: booleanIf module runner is disabled, Vitest uses a module loader to transform files to support
import.meta.vitest and vi.mock.
If you don't use these features, you can disable this.
This option only affects loader.load method, Vitest always defines a loader.resolve to populate the module graph.
OptionalopenTelemetry?: { browserSdkPath?: string; enabled: boolean; sdkPath?: string }OptionalvcsProvider?: string | VCSProviderCustom provider for detecting changed files. Used with the --changed flag
to determine which files have been modified.
By default, Vitest uses Git to detect changed files. You can provide a custom
implementation of the VCSProvider interface to use a different version control system.
OptionalviteModuleRunner?: booleanControls whether Vitest uses Vite's module runner to run the code or fallback to the native import.
If Node.js cannot process the code, consider registering module loader via execArgv.
OptionalfakeOptions for @sinon/fake-timers
OptionalfileShould all test files run in parallel. Doesn't affect tests running in the same file.
Setting this to false will override maxWorkers option to 1.
OptionalforceGlob pattern of file paths that will trigger the whole suite rerun
Useful if you are testing calling CLI commands
OptionalglobalsRegister apis globally
OptionalglobalPath to global setup files
OptionalhideHide logs for skipped tests
OptionalhookDefault timeout of a hook in milliseconds
OptionalincludeA list of glob patterns that match your test files.
OptionalincludeInclude globs for in-source test files
OptionalincludeInclude "location" property inside the test definition
OptionalinspectDebug tests by opening node:inspector in worker / child process.
Provides similar experience as --inspect Node CLI argument.
Requires fileParallelism: false.
OptionalinspectDebug 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.
OptionalinspectorInspector 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
OptionalisolateRun 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.
OptionallistLog all available tags instead of running tests.
OptionallogShow heap usage after each test. Useful for debugging memory leaks.
OptionalmaxA number of tests that are allowed to run at the same time marked with test.concurrent.
OptionalmaxMaximum number or percentage of workers to run tests in.
OptionalmergeDirectory of blob reports to merge
OptionalmockWill call .mockReset() on all spies before each test
OptionalmodeOverrides Vite mode
OptionalnameName of the project. Will be used to display in the reporter.
OptionalonCustom handler for console.log in tests.
Return false to ignore the log.
OptionalonEnable stack trace filtering. If absent, all stack trace frames will be shown.
Return false to omit the frame.
OptionalonA callback that can return false to ignore an unhandled error
OptionalopenOpen UI automatically.
OptionaloutputWrite 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.
Optionaloutputbenchmark.outputJson option exposed at the top level for cli
OptionalpassPass with no tests
OptionalpoolPool used to run tests in.
Supports 'threads', 'forks', 'vmThreads', 'vmForks'
OptionalprintAlways print console stack traces.
OptionalprojectName of the project or projects to run.
OptionalprojectsOptions for projects
OptionalprovideDefine variables that will be returned from inject in the test environment.
OptionalrelatedRun tests that cover a list of source files
OptionalreportersCustom reporter for output. Can contain one or more built-in reporter names, reporter instances, and/or paths to custom reporters.
OptionalresolveResolve custom snapshot path
OptionalrestoreWill call .mockRestore() on all spies before each test
OptionalretryRetry configuration for tests.
⚠️ WARNING: Function form is NOT supported in a config file because configurations are serialized when passed to worker threads. Use the function form only in test files directly.
OptionalrootProject root
OptionalrunnerPath to a custom test runner.
OptionalsequenceOptions for configuring the order of running tests.
OptionalserverOptionalsetupPath to setup files
OptionalshardTest suite shard to execute in a format of count numbers, and run only the indexed part.
Cannot be used with enabled watch.
OptionalsilentSilent mode
Use 'passed-only' to see logs from failing tests only.
OptionalslowThe number of milliseconds after which a test is considered slow and reported as such in the results.
OptionalsnapshotPath to a custom snapshot environment module that has a default export of SnapshotEnvironment object.
OptionalsnapshotFormat options for snapshot testing.
OptionalsnapshotPaths to snapshot serializer modules.
OptionalstandaloneDo 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.
OptionalstrictShould Vitest throw an error if test has a tag that is not defined in the config.
OptionaltagsDefine tags available in your test files.
If test defines a tag that is not listed here, an error will be thrown.
OptionaltagsTags expression to filter tests to run. Multiple filters will be applied using AND logic.
OptionalteardownDefault timeout to wait for close when Vitest shuts down, in milliseconds
OptionaltestRun test names with the specified pattern
OptionaltestDefault timeout of a test in milliseconds
OptionaltypecheckOptions for configuring typechecking test environment.
OptionaluiEnable Vitest UI
OptionaluiBase url for the UI
OptionalunstubWill restore all env stubs to their original values before each test
OptionalunstubWill restore all global stubs to their original values before each test
OptionalupdateUpdate snapshot
OptionalvmSpecifies the memory limit for worker_thread or child_process before they are recycled.
If you see memory leaks, try to tinker this value.
OptionalwatchWatch mode
OptionalwatchPattern configuration to rerun only the tests that are affected by the changes of specific files in the repository.
Specifies an
Object, or anArrayofObject, which defines aliases used to replace values inimportorrequirestatements. Will be merged with the default aliases insideresolve.alias.