Optional aliasOptional allowAllow tests and suites that are marked as only
Optional apiServe API options.
When set to true, the default port is 51204.
false
Optional bailStop test execution when given number of tests have failed.
Optional benchmarkBenchmark options.
{}
Optional Experimental browseroptions for test in a browser environment
false
Optional cacheOptions for configuring cache policy.
Optional dir?: string{ dir: 'node_modules/.vitest' }
Optional chaiModify default Chai config. Vitest uses Chai for expect and assert matches.
https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
Optional changedRuns tests that are affected by the changes in the repository, or between specified branch or commit hash Requires initialized git repository
false
Optional clearWill call .mockClear() on all spies before each test
false
Optional cliAdditional exclude patterns
Optional configPath to the config file.
Default resolving to vitest.config.*, vite.config.*
Setting to false will disable config resolving.
Optional coverageCoverage options
Optional cssIndicates if CSS files should be processed.
When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
Optional exclude?: RegExp | RegExp[]Optional include?: RegExp | RegExp[]Optional modules?: { Optional class{ include: [], modules: { classNameStrategy: false } }
Optional dangerouslyIgnore any unhandled errors that occur
Optional depsHandling for dependencies inlining or externalizing
Optional diffPath to a module which has a default export of diff config.
Optional dirBase directory to scan for the test files
config.root
Optional domUse happy-dom
Optional envCustom environment variables assigned to process.env before running tests.
Optional environmentRunning environment
Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
If used unsupported string, will try to load the package vitest-environment-${env}
'node'
Optional environmentAutomatically assign environment based on globs. The first match will be used. This has effect only when running tests inside Node.js.
Format: [glob, environment-name]
[]
[
// all tests in tests/dom will run in jsdom
['tests/dom/**', 'jsdom'],
// all tests in tests/ with .edge.test.ts will run in edge-runtime
['**/*.edge.test.ts', 'edge-runtime'],
// ...
]
Optional environmentEnvironment options.
Optional excludeExclude globs for test files
['node_modules', 'dist', '.idea', '.git', '.cache']
Optional expandShow full diff when snapshot fails instead of a patch.
Optional fakeOptions for @sinon/fake-timers
Optional fileShould all test files run in parallel. Doesn't affect tests running in the same file.
Setting this to false will override maxWorkers and minWorkers options to 1.
true
Optional forceGlob patter of file paths that will trigger the whole suite rerun
Useful if you are testing calling CLI commands
[]
Optional globalPath to global setup files
Optional globalsRegister apis globally
false
Optional hideHide logs for skipped tests
false
Optional hookDefault timeout of a hook in milliseconds
10000
Optional includeInclude globs for test files
['**/*.{test,spec}.?(c|m)[jt]s?(x)']
Optional includeInclude globs for in-source test files
[]
Optional inspectDebug tests by opening node:inspector in worker / child process.
Provides similar experience as --inspect Node CLI argument.
Requires poolOptions.threads.singleThread: true OR poolOptions.forks.singleFork: true.
Optional inspectDebug 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 poolOptions.threads.singleThread: true OR poolOptions.forks.singleFork: true.
Optional isolateRun tests in an isolated environment. This option has no effect on vmThreads pool.
Disabling this option might improve performance if your code doesn't rely on side effects.
true
Optional logShow heap usage after each test. Useful for debugging memory leaks.
Optional maxA number of tests that are allowed to run at the same time marked with test.concurrent.
5
Optional maxMaximum number of workers to run tests in. poolOptions.{threads,vmThreads}.maxThreads/poolOptions.forks.maxForks has higher priority.
Optional minMinimum number of workers to run tests in. poolOptions.{threads,vmThreads}.minThreads/poolOptions.forks.minForks has higher priority.
Optional mockWill call .mockReset() on all spies before each test
false
Optional modeOverrides Vite mode
'test'
Optional nameName of the project. Will be used to display in the reporter.
Optional onCustom handler for console.log in tests.
Return false to ignore the log.
Custom handler for console.log in tests.
Return false to ignore the log.
Optional onEnable stack trace filtering. If absent, all stack trace frames will be shown.
Return false to omit the frame.
Enable stack trace filtering. If absent, all stack trace frames will be shown.
Return false to omit the frame.
Optional openOpen UI automatically.
true
Optional outputWrite 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.
Optional passPass with no tests
Optional poolPool used to run tests in.
Supports 'threads', 'forks', 'vmThreads'
'threads'
Optional poolAutomatically assign pool based on globs. The first match will be used.
Format: [glob, pool-name]
[]
[
// all tests in "forks" directory will run using "poolOptions.forks" API
['tests/forks/**', 'forks'],
// all other tests will run based on "poolOptions.threads" option, if you didn't specify other globs
// ...
]
Optional poolPool options
Optional projectName of the project or projects to run.
Optional relatedRun tests that cover a list of source files
Optional reportersCustom reporter for output. Can contain one or more built-in report names, reporter instances, and/or paths to custom reporters.
Optional resolveResolve custom snapshot path
Resolve custom snapshot path
Optional restoreWill call .mockRestore() on all spies before each test
false
Optional retryRetry the test specific number of times if it fails.
0
Optional rootProject root
process.cwd()
Optional runnerPath to a custom test runner.
Optional sequenceOptions for configuring the order of running tests.
Optional serverVite-node server options
Optional setupPath to setup files
Optional shardTest suite shard to execute in a format of count numbers, and run only the indexed part.
Cannot be used with enabled watch.
--shard=2/3
Optional silentSilent mode
false
Optional slowThe number of milliseconds after which a test is considered slow and reported as such in the results.
300
Optional snapshotFormat options for snapshot testing.
Optional teardownDefault timeout to wait for close when Vitest shuts down, in milliseconds
10000
Optional testrun test names with the specified pattern
Optional testDefault timeout of a test in milliseconds
5000
Optional testDetermine the transform method for all modules imported inside a test that matches the glob pattern.
Optional typecheckOptions for configuring typechecking test environment.
Optional Internal uiEnable Vitest UI
Optional uiBase url for the UI
'/__vitest__/'
Optional unstubWill restore all env stubs to their original values before each test
false
Optional unstubWill restore all global stubs to their original values before each test
false
Optional updateUpdate snapshot
false
Optional watchWatch mode
true
Optional watchGlob pattern of file paths to be ignore from triggering watch rerun
Optional workspacePath to a workspace configuration file
Generated using TypeDoc
Specifies an
Object, or anArrayofObject, which defines aliases used to replace values inimportorrequirestatements. Will be merged with the default aliases insideresolve.alias.