new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Vitest · Guide · all subjects

cli commands & flags

67 notes in this subject, read out of this brain and free to use. This is page 1 of 2.

UI flag enables Vitest UI mode

The `--ui` CLI flag enables the Vitest UI interface for visual test running and monitoring.

slowTestThreshold flag sets slow test threshold

The `--slowTestThreshold <threshold>` CLI flag sets the threshold in milliseconds for a test or suite to be considered slow. Default is `300`.

api.allowWrite security implication

The `--api.allowWrite` CLI flag allows the API to edit files. The documentation warns: be careful when enabling this option in untrusted environments, as it grants file modification capabilities.

root CLI flag and config option

The `-r, --root <path>` CLI flag specifies the root path for test execution. It can also be configured via the `root` config option.

config flag specifies config file path

The `-c, --config <path>` CLI flag specifies the path to a Vitest config file.

update flag controls snapshot updates

The `-u, --update [type]` CLI flag updates snapshots. It accepts boolean, "new", "all", or "none" as values.

watch mode CLI flag

The `-w, --watch` CLI flag enables watch mode for automatic test re-running on file changes.

testNamePattern flag runs tests matching pattern

The `-t, --testNamePattern <pattern>` CLI flag runs only tests with full names matching the specified regexp pattern.

dir flag sets base directory for test scanning

The `--dir <path>` CLI flag specifies the base directory to scan for test files.

api.port flag specifies server port

The `--api.port [port]` CLI flag specifies the server port for the Vitest API. If the port is already in use, Vite automatically tries the next available port. If true is set, it defaults to 51204.

api.host flag specifies server listening address

The `--api.host [host]` CLI flag specifies which IP addresses the server should listen on. Set to `0.0.0.0` or `true` to listen on all addresses including LAN and public addresses.

api.strictPort flag fails if port in use

The `--api.strictPort` CLI flag causes Vitest to exit if the specified port is already in use, instead of automatically trying the next available port.

api.allowExec flag allows code execution

The `--api.allowExec` CLI flag allows the API to execute code. The documentation warns: be careful when enabling this option in untrusted environments.

silent flag suppresses console output

The `--silent [value]` CLI flag silences console output from tests. Use the value `'passed-only'` to see logs only from failing tests.

hideSkippedTests flag hides skipped test logs

The `--hideSkippedTests` CLI flag hides logs for tests marked as skipped.

mode flag overrides Vite mode

The `--mode <name>` CLI flag overrides the Vite mode. Default is `test`.

isolate flag runs tests in isolation

The `--isolate` CLI flag runs every test file in isolation. Use `--no-isolate` to disable isolation. Default is `true`.

globals flag injects APIs globally

The `--globals` CLI flag injects Vitest APIs globally without requiring imports in test files.

injectCjsGlobals flag injects CommonJS variables

The `--injectCjsGlobals` CLI flag injects CommonJS variables (`module`, `exports`, `require`, `__filename`, `__dirname`) into every test module. Use `--no-inject-cjs-globals` to disable. Default is `true`.

dom flag mocks browser API with happy-dom

The `--dom` CLI flag mocks browser API using happy-dom library.

pool flag specifies execution pool

The `--pool <pool>` CLI flag specifies which pool to use when not running in browser. Default is `forks`.

execArgv flag passes arguments to node process

The `--execArgv <option>` CLI flag passes additional arguments to the `node` process when spawning `worker_threads` or `child_process`.

vmMemoryLimit flag sets VM memory limit

The `--vmMemoryLimit <limit>` CLI flag sets memory limit for VM pools. Adjust this value if you encounter memory leaks.

passWithNoTests flag passes when no tests found

The `--passWithNoTests` CLI flag causes test execution to pass when no tests are found.

logHeapUsage flag shows memory per test

The `--logHeapUsage` CLI flag shows the size of heap for each test when running in node environment.

detectAsyncLeaks flag detects leaked resources

The `--detectAsyncLeaks` CLI flag detects asynchronous resources leaking from test files. Default is `false`.

allowOnly flag allows .only tests

The `--allowOnly` CLI flag allows tests and suites marked with `.only()`. Default is `!process.env.CI`.

dangerouslyIgnoreUnhandledErrors flag ignores errors

The `--dangerouslyIgnoreUnhandledErrors` CLI flag ignores any unhandled errors that occur during test execution.

changed flag runs affected tests

The `--changed [since]` CLI flag runs tests that are affected by changed files. Default is `false`.

inspect flag enables Node.js inspector

The `--inspect [[host:]port]` CLI flag enables Node.js inspector. Default is `127.0.0.1:9229`.

inspectBrk flag enables inspector with breakpoint

The `--inspectBrk [[host:]port]` CLI flag enables Node.js inspector and breaks before the test starts.

testTimeout flag sets test timeout

The `--testTimeout <timeout>` CLI flag sets the default timeout for a test in milliseconds. Default is `5000`. Use `0` to disable timeout.

bail flag stops on failure count

The `--bail <number>` CLI flag stops test execution when the given number of tests have failed. Default is `0`.

retry.count flag retries failed tests

The `--retry.count <times>` CLI flag sets the number of times to retry a test if it fails. Default is `0`.

retry.delay flag sets delay between retries

The `--retry.delay <ms>` CLI flag sets the delay in milliseconds between retry attempts. Default is `0`.

retry.condition flag filters errors for retry

The `--retry.condition <pattern>` CLI flag specifies a regex pattern to match error messages that should trigger a retry. Only errors matching this pattern cause a retry. Default is retry on all errors.

repeats flag repeats tests multiple times

The `--repeats <number>` CLI flag repeats every test a specific number of times regardless of the result. Default is `0`.

exclude flag adds exclusion patterns

The `--exclude <glob>` CLI flag specifies additional file globs to be excluded from test execution.

disableConsoleIntercept flag disables console interception

The `--disableConsoleIntercept` CLI flag disables automatic interception of console logging. Default is `false`.

fsModuleCache flag enables module caching

The `--fsModuleCache` CLI flag caches transformed modules on the file system and reuses them between reruns. Default is `false`.

fsModuleCachePath flag sets cache directory

The `--fsModuleCachePath <path>` CLI flag specifies the directory where `fsModuleCache` is stored. Default is `node_modules/.vitest-cache`.

printConsoleTrace flag prints console traces

The `--printConsoleTrace` CLI flag always prints console stack traces.

includeTaskLocation flag collects task locations

The `--includeTaskLocation` CLI flag collects test and suite locations in the `location` property.

attachmentsDir flag sets attachments directory

The `--attachmentsDir <dir>` CLI flag specifies the directory where attachments from `context.annotate` are stored. Default is `.vitest/attachments`.

run flag disables watch mode

The `--run` CLI flag disables watch mode and runs tests once.

no-color flag removes console colors

The `--no-color` CLI flag removes colors from console output.

clearScreen flag clears screen on rerun

The `--clearScreen` CLI flag clears terminal screen when re-running tests during watch mode. Default is `true`.

configLoader flag selects config processing method

The `--configLoader <loader>` CLI flag selects how to process config. Use `bundle` to bundle with esbuild or `runner` (experimental) to process on the fly. Only available in Vite 6.1.0+. Default is `bundle`.

standalone flag starts without running tests

The `--standalone` CLI flag starts Vitest without running tests initially. Tests run only on file changes. With browser mode enabled, the UI opens automatically. Ignored when CLI file filters are passed. Default is `false`.

listTags flag lists available tags

The `--listTags [type]` CLI flag lists all available tags instead of running tests. Use `--list-tags=json` for JSON format output when tags exist.

clearCache flag deletes Vitest caches

The `--clearCache` CLI flag deletes all Vitest caches, including `fsModuleCache`, without running tests. This reduces performance in the subsequent test run.

tagsFilter flag filters tests by tags

The `--tagsFilter <expression>` CLI flag runs only tests with specified tags. Supports logical operators: `&&` (and), `||` (or), `!` (not) for complex expressions.

strictTags flag enforces tag definition

The `--strictTags` CLI flag causes Vitest to throw an error if a test has a tag not defined in the config. Default is `true`.

sharedViteServer flag enables server reuse

The `--sharedViteServer` CLI flag lets inline projects that don't modify the Vite config reuse the Vite server of the config that declares them. Default is `true`.

experimental.importDurations.print flag controls import printing

The `--experimental.importDurations.print <boolean|on-warn>` CLI flag controls when to print import breakdown to CLI. Use `true` to always print, `false` to never print, or `on-warn` to print only when imports exceed the warn threshold. Default is `false`.

experimental.importDurations.limit flag limits import collection

The `--experimental.importDurations.limit <number>` CLI flag sets the maximum number of imports to collect and display. Default is 0, or 10 if print or UI is enabled.

experimental.importDurations.failOnDanger flag fails on threshold

The `--experimental.importDurations.failOnDanger` CLI flag causes test run to fail if any import exceeds the danger threshold. Default is `false`.

experimental.importDurations thresholds configuration

Import duration thresholds: `--experimental.importDurations.thresholds.warn <number>` (warning threshold shown in yellow/orange, default: 100) and `--experimental.importDurations.thresholds.danger <number>` (danger threshold shown in red, default: 500).

experimental.viteModuleRunner flag controls module execution

The `--experimental.viteModuleRunner` CLI flag controls whether Vitest uses Vite's module runner or falls back to native `import`. Default is `true`.

experimental.nodeLoader flag controls Node.js Loader API

The `--experimental.nodeLoader` CLI flag controls whether Vitest uses Node.js Loader API to process in-source or mocked files. Has no effect if `viteModuleRunner` is enabled. Disabling can increase performance. Default is `true`.

Give your agent this brain