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