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
Provider to use for coverage collection.
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
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.
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.
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.
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 report names, reporter instances, and/or paths to custom reporters.
OptionalresolveResolve custom snapshot path
OptionalrestoreWill call .mockRestore() on all spies before each test
OptionalretryRetry the test specific number of times if it fails.
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.
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.