Running Tests
Run all tests in watch mode
$vitestRun all tests once without watch mode
$vitest runRun all tests in explicit watch mode, re-running on file changes
$vitest watchAlias for vitest watch — run tests in interactive watch mode
$vitest devRun tests matching a specific file path or pattern once
$vitest run src/utilsRun a single specific test file once
$vitest run src/utils/math.test.tsRun all tests once with verbose output showing each test name
$vitest run --reporter=verboseRun all tests once with minimal dot-style reporter output
$vitest run --reporter=dotRun all tests once and output results as JSON to stdout
$vitest run --reporter=jsonRun all tests and write JSON results to a file
$vitest run --reporter=json --outputFile=results.jsonRun all tests and output results in JUnit XML format
$vitest run --reporter=junitRun all tests and write JUnit XML results to a file
$vitest run --reporter=junit --outputFile=junit.xmlRun all tests and generate an HTML report
$vitest run --reporter=htmlRun tests with multiple reporters simultaneously
$vitest run --reporter=verbose --reporter=json --outputFile=results.jsonRun all tests suppressing console output from test files
$vitest run --silentStop running tests after the first test failure
$vitest run --bail=1Stop running tests after 3 test failures
$vitest run --bail=3Run tests without ANSI color codes in the output
$vitest run --no-colorAllow test.only and describe.only in CI without throwing an error
$vitest run --allowOnlyExit with code 0 even when no test files are found
$vitest run --passWithNoTestsRun tests hiding skipped test entries from the output
$vitest run --hideSkippedTestsRun only tests whose names match a given regex pattern
$vitest --testNamePattern="should return"Run once only tests whose names contain the word auth
$vitest run --testNamePattern="auth"Run tests for a specific named project in a multi-project setup
$vitest run --project=frontendRun tests for multiple specified projects in a multi-project setup
$vitest run --project=frontend --project=backendWatch Mode
Run only tests related to files changed since the last git commit
$vitest --changedRun only tests related to files changed in the last git commit
$vitest --changed HEAD~1Run only tests related to files changed compared to origin/main
$vitest --changed origin/mainForce a full test rerun when files in a specific path change
$vitest --force-rerun-triggers src/utilsRun in watch mode with verbose output showing individual test names
$vitest --watch --reporter=verboseCoverage
Run all tests once and collect code coverage using the default provider
$vitest run --coverageRun tests in watch mode with code coverage enabled
$vitest --coverageRun tests with coverage using the V8 native coverage provider
$vitest run --coverage --coverage.provider=v8Run tests with coverage using the Istanbul coverage provider
$vitest run --coverage --coverage.provider=istanbulRun tests and output a text coverage summary to the terminal
$vitest run --coverage --coverage.reporter=textRun tests and generate an lcov coverage report
$vitest run --coverage --coverage.reporter=lcovRun tests and generate an HTML coverage report
$vitest run --coverage --coverage.reporter=htmlRun tests and generate a JSON coverage report
$vitest run --coverage --coverage.reporter=jsonRun tests generating both text and HTML coverage reports
$vitest run --coverage --coverage.reporter=text --coverage.reporter=htmlCollect coverage only for files matching the specified glob pattern
$vitest run --coverage --coverage.include="src/**"Exclude specific files from coverage collection
$vitest run --coverage --coverage.exclude="src/**/*.d.ts"Include all project files in coverage even if they have no tests
$vitest run --coverage --coverage.allFail the run if line coverage falls below 80 percent
$vitest run --coverage --coverage.thresholds.lines=80Fail the run if function coverage falls below 80 percent
$vitest run --coverage --coverage.thresholds.functions=80Fail the run if branch coverage falls below 80 percent
$vitest run --coverage --coverage.thresholds.branches=80Fail the run if statement coverage falls below 80 percent
$vitest run --coverage --coverage.thresholds.statements=80Write coverage reports to a specific output directory
$vitest run --coverage --coverage.reportsDirectory=./coverageConfiguration
Run tests using a specific Vitest configuration file
$vitest run --config vitest.config.tsRun tests using a configuration file at a custom path
$vitest run --config ./config/vitest.config.tsSet the root directory for test file discovery
$vitest run --root ./packages/coreRun tests only in files found within a specific directory
$vitest run --dir srcRun tests in a Node.js environment
$vitest run --environment nodeRun tests in a jsdom browser-simulated environment
$vitest run --environment jsdomRun tests in a happy-dom browser-simulated environment
$vitest run --environment happy-domRun tests in an edge runtime environment
$vitest run --environment edge-runtimeRun tests with Vitest globals like describe and expect injected without imports
$vitest run --globalsRun each test file in an isolated module environment
$vitest run --isolateDisable module isolation, sharing module state across test files
$vitest run --no-isolateRun tests using worker threads pool
$vitest run --pool=threadsRun tests using child process forks pool
$vitest run --pool=forksRun tests in a VM context within worker threads
$vitest run --pool=vmThreadsRun tests in a VM context within child process forks
$vitest run --pool=vmForksSet the maximum number of worker threads for the threads pool
$vitest run --poolOptions.threads.maxThreads=4Set the minimum number of worker threads for the threads pool
$vitest run --poolOptions.threads.minThreads=1Set the maximum number of child process forks
$vitest run --poolOptions.forks.maxForks=4Run all tests in a single worker thread sequentially
$vitest run --singleThreadRun all tests in a single child process fork sequentially
$vitest run --singleForkLimit the number of concurrent worker processes or threads
$vitest run --maxWorkers=4Set the minimum number of concurrent worker processes or threads
$vitest run --minWorkers=1Run test files and suites in a randomized order
$vitest run --sequence.shuffleRun tests in a shuffled order seeded with a specific value for reproducibility
$vitest run --sequence.seed=42Run tests within each file concurrently
$vitest run --sequence.concurrentDisable worker threads, running tests in the main process
$vitest run --no-threadsRun tests with Node.js inspector enabled for debugging
$vitest run --inspectRun tests with Node.js inspector enabled, pausing on the first line
$vitest run --inspect-brkLog heap memory usage after each test for memory profiling
$vitest run --logHeapUsageDisable interception and buffering of console output during tests
$vitest run --disable-console-interceptFiltering & Targeting
Run all tests within the src/auth directory
$vitest run src/authRun tests whose file paths match both auth and login
$vitest run auth loginExclude tests matching a path pattern from the run
$vitest run --exclude src/legacyRun only test files matching a specific glob pattern
$vitest run --include="**/*.spec.ts"Run test files matching multiple glob patterns
$vitest run --include="**/*.test.ts" --include="**/*.spec.ts"Set the timeout in milliseconds for each individual test
$vitest run --testTimeout=10000Set the timeout in milliseconds for before and after hooks
$vitest run --hookTimeout=10000Set the timeout in milliseconds for teardown functions
$vitest run --teardownTimeout=5000Retry failing tests up to 3 times before marking them as failed
$vitest run --retry=3Repeat every test 5 times to detect flakiness
$vitest run --repeat=5UI Mode
Open the Vitest browser UI for interactive test inspection
$vitest --uiStart the Vitest UI server without auto-opening the browser
$vitest --ui --open=falseOpen the Vitest UI with code coverage enabled
$vitest --ui --coverageStart the Vitest UI server on a specific port
$vitest --ui --port=51205Browser Mode
Run tests in a real browser environment using the default provider
$vitest run --browserRun tests in a Chromium browser instance
$vitest run --browser=chromiumRun tests in a Firefox browser instance
$vitest run --browser=firefoxRun tests in a WebKit browser instance
$vitest run --browser=webkitRun browser tests in headless mode without opening a visible window
$vitest run --browser --browser.headlessRun browser tests using Playwright as the browser provider
$vitest run --browser --browser.provider=playwrightRun browser tests using WebdriverIO as the browser provider
$vitest run --browser --browser.provider=webdriverioBenchmark
Run all benchmark files in watch mode
$vitest benchRun all benchmark files once without watch mode
$vitest bench --runRun a specific benchmark file once
$vitest bench --run src/utils.bench.tsRun benchmarks once with verbose output showing all results
$vitest bench --run --reporter=verboseRun benchmarks once and write results to a JSON file
$vitest bench --run --outputFile=benchmark-results.jsonType Checking
Run type checking on test files using TypeScript without executing tests
$vitest typecheckRun type checking on test files once without watch mode
$vitest typecheck --runRun type checking only on test files matching a path pattern
$vitest typecheck src/authRun tests and type checking simultaneously
$vitest run --typecheckRun only type checking, skipping actual test execution
$vitest run --typecheck.onlyRun type checking using tsc as the type checker
$vitest run --typecheck --typecheck.checker=tscRun type checking using vue-tsc for Vue project test files
$vitest run --typecheck --typecheck.checker=vue-tscMiscellaneous
Display the currently installed version of Vitest
$vitest --versionDisplay help information and all available CLI options
$vitest --helpList all test files that would be collected without running them
$vitest listList test files matching a path pattern without running them
$vitest list src/authList collected test files and output as JSON
$vitest list --jsonUpdate all outdated snapshot files to match current output
$vitest run --updateUpdate snapshots only for test files matching a path pattern
$vitest run --update src/componentsRun in watch mode updating snapshots automatically on change
$vitest run --watch --updateClear the Vitest transform cache and exit
$vitest run --clearCacheDisable transform caching for this run
$vitest run --cache=falseUse a custom directory for the transform cache
$vitest run --cacheDir=.vitest-cacheUse a custom diff configuration file for test failure output
$vitest run --diff=vitest-diff-options.tsShow the full diff in snapshot failure output without truncation
$vitest run --expand-snapshot-diffPrint a stack trace alongside each console.log call in tests
$vitest run --printConsoleTraceRetry a test suite if it exits with a segfault up to 3 times
$vitest run --segfaultRetry=3