···11+| Options | |
22+| ------------- | ------------- |
33+| `-r, --root <path>` | Root path |
44+| `-c, --config <path>` | Path to config file |
55+| `-u, --update` | Update snapshot |
66+| `-w, --watch` | Enable watch mode |
77+| `-t, --testNamePattern <pattern>` | Run tests with full names matching the specified regexp pattern |
88+| `--dir <path>` | Base directory to scan for the test files |
99+| `--ui` | Enable UI |
1010+| `--open` | Open UI automatically (default: `!process.env.CI`) |
1111+| `--port [port]` | Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to `51204` |
1212+| `--host [host]` | Specify which IP addresses the server should listen on. Set this to `0.0.0.0` or `true` to listen on all addresses, including LAN and public addresses |
1313+| `--strictPort` | Set to true to exit if port is already in use, instead of automatically trying the next available port |
1414+| `--silent` | Silent console output from tests |
1515+| `--hideSkippedTests` | Hide logs for skipped tests |
1616+| `--reporter <name>` | Specify reporters |
1717+| `--outputFile <filename/-s>` | Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters (example: --outputFile.tap=./tap.txt) |
1818+| `--all` | Whether to include all files, including the untested ones into report |
1919+| `--provider <name>` | Select the tool for coverage collection, available values are: "v8", "istanbul" and "custom" |
2020+| `--enabled` | Enables coverage collection. Can be overridden using the `--coverage` CLI option (default: `false`) |
2121+| `--include <pattern>` | Files included in coverage as glob patterns. May be specified more than once when using multiple patterns (default: `**`) |
2222+| `--exclude <pattern>` | Files to be excluded in coverage. May be specified more than once when using multiple extensions (default: Visit [`coverage.exclude`](https://vitest.dev/config/#coverage-exclude)) |
2323+| `--extension <extension>` | Extension to be included in coverage. May be specified more than once when using multiple extensions (default: `[".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"]`) |
2424+| `--clean` | Clean coverage results before running tests (default: true) |
2525+| `--cleanOnRerun` | Clean coverage report on watch rerun (default: true) |
2626+| `--reportsDirectory <path>` | Directory to write coverage report to (default: ./coverage) |
2727+| `--reporter <name>` | Coverage reporters to use. Visit [`coverage.reporter`](https://vitest.dev/config/#coverage-reporter) for more information (default: `["text", "html", "clover", "json"]`) |
2828+| `--reportOnFailure` | Generate coverage report even when tests fail (default: false) |
2929+| `--allowExternal` | Collect coverage of files outside the project root (default: false) |
3030+| `--skipFull` | Do not show files with 100% statement, branch, and function coverage (default: false) |
3131+| `--100` | Shortcut to set all coverage thresholds to 100 (default: `false`) |
3232+| `--perFile` | Check thresholds per file. See `--coverage.thresholds.lines`, `--coverage.thresholds.functions`, `--coverage.thresholds.branches` and `--coverage.thresholds.statements` for the actual thresholds (default: `false`) |
3333+| `--autoUpdate` | Update threshold values: "lines", "functions", "branches" and "statements" to configuration file when current coverage is above the configured thresholds (default: `false`) |
3434+| `--lines <number>` | Threshold for lines. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers |
3535+| `--functions <number>` | Threshold for functions. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers |
3636+| `--branches <number>` | Threshold for branches. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers |
3737+| `--statements <number>` | Threshold for statements. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers |
3838+| `--ignoreClassMethods <name>` | Array of class method names to ignore for coverage. Visit [istanbuljs](https://github.com/istanbuljs/nyc#ignoring-methods) for more information. This option is only available for the istanbul providers (default: `[]`) |
3939+| `--processingConcurrency <number>` | Concurrency limit used when processing the coverage results. (default min between 20 and the number of CPUs) |
4040+| `--customProviderModule <path>` | Specifies the module name or path for the custom coverage provider module. Visit [Custom Coverage Provider](https://vitest.dev/guide/coverage#custom-coverage-provider) for more information. This option is only available for custom providers |
4141+| `--statements <watermarks>` | High and low watermarks for statements in the format of `<high>,<low>` |
4242+| `--lines <watermarks>` | High and low watermarks for lines in the format of `<high>,<low>` |
4343+| `--branches <watermarks>` | High and low watermarks for branches in the format of `<high>,<low>` |
4444+| `--functions <watermarks>` | High and low watermarks for functions in the format of `<high>,<low>` |
4545+| `--mode <name>` | Override Vite mode (default: `test` or `benchmark`) |
4646+| `--workspace <path>` | Path to a workspace configuration file |
4747+| `--isolate` | Run every test file in isolation. To disable isolation, use `--no-isolate` (default: `true`) |
4848+| `--globals` | Inject apis globally |
4949+| `--dom` | Mock browser API with happy-dom |
5050+| `--enabled` | Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`) |
5151+| `--name <name>` | Run all tests in a specific browser. Some browsers are only available for specific providers (see `--browser.provider`). Visit [`browser.name`](https://vitest.dev/config/#browser-name) for more information |
5252+| `--headless` | Run the browser in headless mode (i.e. without opening the GUI (Graphical User Interface)). If you are running Vitest in CI, it will be enabled by default (default: `process.env.CI`) |
5353+| `--port [port]` | Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to `63315` |
5454+| `--host [host]` | Specify which IP addresses the server should listen on. Set this to `0.0.0.0` or `true` to listen on all addresses, including LAN and public addresses |
5555+| `--strictPort` | Set to true to exit if port is already in use, instead of automatically trying the next available port |
5656+| `--provider <name>` | Provider used to run browser tests. Some browsers are only available for specific providers. Can be "webdriverio", "playwright", or the path to a custom provider. Visit [`browser.provider`](https://vitest.dev/config/#browser-provider) for more information (default: `"webdriverio"`) |
5757+| `--providerOptions <options>` | Options that are passed down to a browser provider. Visit [`browser.providerOptions`](https://vitest.dev/config/#browser-provideroptions) for more information |
5858+| `--slowHijackESM` | Let Vitest use its own module resolution on the browser to enable APIs such as vi.mock and vi.spyOn. Visit [`browser.slowHijackESM`](https://vitest.dev/config/#browser-slowhijackesm) for more information (default: `false`) |
5959+| `--isolate` | Run every browser test file in isolation. To disable isolation, use `--browser.isolate=false` (default: `true`) |
6060+| `--fileParallelism` | Should all test files run in parallel. Use `--browser.file-parallelism=false` to disable (default: same as `--file-parallelism`) |
6161+| `--pool <pool>` | Specify pool, if not running in the browser (default: `threads`) |
6262+| `--isolate` | Isolate tests in threads pool (default: `true`) |
6363+| `--singleThread` | Run tests inside a single thread (default: `false`) |
6464+| `--maxThreads <workers>` | Maximum number of threads to run tests in |
6565+| `--minThreads <workers>` | Minimum number of threads to run tests in |
6666+| `--useAtomics` | Use Atomics to synchronize threads. This can improve performance in some cases, but might cause segfault in older Node versions (default: `false`) |
6767+| `--isolate` | Isolate tests in threads pool (default: `true`) |
6868+| `--singleThread` | Run tests inside a single thread (default: `false`) |
6969+| `--maxThreads <workers>` | Maximum number of threads to run tests in |
7070+| `--minThreads <workers>` | Minimum number of threads to run tests in |
7171+| `--useAtomics` | Use Atomics to synchronize threads. This can improve performance in some cases, but might cause segfault in older Node versions (default: `false`) |
7272+| `--memoryLimit <limit>` | Memory limit for VM threads pool. If you see memory leaks, try to tinker this value. |
7373+| `--isolate` | Isolate tests in threads pool (default: `true`) |
7474+| `--singleFork` | Run tests inside a single child_process (default: `false`) |
7575+| `--maxForks <workers>` | Maximum number of processes to run tests in |
7676+| `--minForks <workers>` | Minimum number of processes to run tests in |
7777+| `--isolate` | Isolate tests in threads pool (default: `true`) |
7878+| `--singleFork` | Run tests inside a single child_process (default: `false`) |
7979+| `--maxForks <workers>` | Maximum number of processes to run tests in |
8080+| `--minForks <workers>` | Minimum number of processes to run tests in |
8181+| `--memoryLimit <limit>` | Memory limit for VM forks pool. If you see memory leaks, try to tinker this value. |
8282+| `--fileParallelism` | Should all test files run in parallel. Use `--no-file-parallelism` to disable (default: `true`) |
8383+| `--maxWorkers <workers>` | Maximum number of workers to run tests in |
8484+| `--minWorkers <workers>` | Minimum number of workers to run tests in |
8585+| `--environment <name>` | Specify runner environment, if not running in the browser (default: `node`) |
8686+| `--passWithNoTests` | Pass when no tests are found |
8787+| `--logHeapUsage` | Show the size of heap for each test when running in node |
8888+| `--allowOnly` | Allow tests and suites that are marked as only (default: `!process.env.CI`) |
8989+| `--dangerouslyIgnoreUnhandledErrors` | Ignore any unhandled errors that occur |
9090+| `--shard <shards>` | Test suite shard to execute in a format of `<index>/<count>` |
9191+| `--changed [since]` | Run tests that are affected by the changed files (default: `false`) |
9292+| `--files` | Run files in a random order. Long running tests will not start earlier if you enable this option. (default: `false`) |
9393+| `--tests` | Run tests in a random oder (default: `false`) |
9494+| `--concurrent` | Make tests run in parallel (default: `false`) |
9595+| `--seed <seed>` | Set the randomization seed. This option will have no effect if --sequence.shuffle is falsy. Visit ["Random Seed" page](https://en.wikipedia.org/wiki/Random_seed) for more information |
9696+| `--hooks <order>` | Changes the order in which hooks are executed. Accepted values are: "stack", "list" and "parallel". Visit [`sequence.hooks`](https://vitest.dev/config/#sequence-hooks) for more information (default: `"parallel"`) |
9797+| `--setupFiles <order>` | Changes the order in which setup files are executed. Accepted values are: "list" and "parallel". If set to "list", will run setup files in the order they are defined. If set to "parallel", will run setup files in parallel (default: `"parallel"`) |
9898+| `--inspect [[host:]port]` | Enable Node.js inspector (default: `127.0.0.1:9229`) |
9999+| `--inspectBrk [[host:]port]` | Enable Node.js inspector and break before the test starts |
100100+| `--testTimeout <timeout>` | Default timeout of a test in milliseconds (default: `5000`) |
101101+| `--hookTimeout <timeout>` | Default hook timeout in milliseconds (default: `10000`) |
102102+| `--bail <number>` | Stop test execution when given number of tests have failed (default: `0`) |
103103+| `--retry <times>` | Retry the test specific number of times if it fails (default: `0`) |
104104+| `--diff <path>` | Path to a diff config that will be used to generate diff interface |
105105+| `--exclude <glob>` | Additional file globs to be excluded from test |
106106+| `--expandSnapshotDiff` | Show full diff when snapshot fails |
107107+| `--disableConsoleIntercept` | Disable automatic interception of console logging (default: `false`) |
108108+| `--enabled` | Enable typechecking alongside tests (default: `false`) |
109109+| `--only` | Run only typecheck tests. This automatically enables typecheck (default: `false`) |
110110+| `--checker <name>` | Specify the typechecker to use. Available values are: "tcs" and "vue-tsc" and a path to an executable (default: `"tsc"`) |
111111+| `--allowJs` | Allow JavaScript files to be typechecked. By default takes the value from tsconfig.json |
112112+| `--ignoreSourceErrors` | Ignore type errors from source files |
113113+| `--tsconfig <path>` | Path to a custom tsconfig file |
114114+| `--project <name>` | The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: `--project=1 --project=2`. You can also filter projects using wildcards like `--project=packages*` |
115115+| `--slowTestThreshold <threshold>` | Threshold in milliseconds for a test to be considered slow (default: `300`) |
116116+| `--teardownTimeout <timeout>` | Default timeout of a teardown function in milliseconds (default: `10000`) |
117117+| `--maxConcurrency <number>` | Maximum number of concurrent tests in a suite (default: `5`) |
118118+| `--run` | Disable watch mode |
119119+| `--segfaultRetry <times>` | Retry the test suite if it crashes due to a segfault (default: `true`) |
120120+| `--no-color` | Removes colors from the console output |
121121+| `--clearScreen` | Clear terminal screen when re-running tests during watch mode (default: `true`) |
+1-52
docs/guide/cli.md
···57575858## Options
59596060-| Options | |
6161-| ------------- | ------------- |
6262-| `-v, --version` | Display version number |
6363-| `-r, --root <path>` | Define the project root |
6464-| `-c, --config <path>` | Path to config file |
6565-| `-u, --update` | Update snapshots |
6666-| `-w, --watch` | Smart & instant watch mode |
6767-| `-t, --testNamePattern <pattern>` | Run tests with full names matching the pattern |
6868-| `--dir <path>`| Base directory to scan for the test files |
6969-| `--ui` | Enable UI |
7070-| `--open` | Open the UI automatically if enabled (default: `true`) |
7171-| `--api [api]` | Serve API, available options: `--api.port <port>`, `--api.host [host]` and `--api.strictPort` |
7272-| `--pool <pool>` | Specify pool, if not running in the browser (default: `threads`) |
7373-| `--poolOptions <options>` | Specify pool options |
7474-| `--poolOptions.threads.isolate` | Isolate tests in threads pool (default: `true`) |
7575-| `--poolOptions.forks.isolate` | Isolate tests in forks pool (default: `true`) |
7676-| `--fileParallelism` | Should all test files run in parallel. Use --no-file-parallelism to disable (default: true) |
7777-| `--maxWorkers <workers>` | Maximum number of workers to run tests in |
7878-| `--minWorkers <workers>` | Minimum number of workers to run tests in |
7979-| `--silent` | Silent console output from tests |
8080-| `--reporter <name>` | Select reporter: `default`, `verbose`, `dot`, `junit`, `json`, or a path to a custom reporter |
8181-| `--outputFile <filename/-s>` | Write test results to a file when the `--reporter=json` or `--reporter=junit` option is also specified <br /> Via [cac's dot notation] you can specify individual outputs for multiple reporters |
8282-| `--coverage` | Enable coverage report |
8383-| `--run` | Do not watch |
8484-| `--isolate` | Run every test file in isolation. To disable isolation, use --no-isolate (default: `true`) |
8585-| `--mode <name>` | Override Vite mode (default: `test`) |
8686-| `--workspace <path>` | Path to a workspace configuration file |
8787-| `--globals` | Inject APIs globally |
8888-| `--dom` | Mock browser API with happy-dom |
8989-| `--browser [options]` | Run tests in [the browser](/guide/browser) (default: `false`) |
9090-| `--environment <env>` | Runner environment (default: `node`) |
9191-| `--passWithNoTests` | Pass when no tests found |
9292-| `--logHeapUsage` | Show the size of heap for each test |
9393-| `--allowOnly` | Allow tests and suites that are marked as `only` (default: false in CI, true otherwise) |
9494-| `--dangerouslyIgnoreUnhandledErrors` | Ignore any unhandled errors that occur |
9595-| `--changed [since]` | Run tests that are affected by the changed files (default: false). See [docs](#changed) |
9696-| `--shard <shard>` | Execute tests in a specified shard |
9797-| `--sequence` | Define in what order to run tests. Use [cac's dot notation] to specify options (for example, use `--sequence.shuffle` to run tests in random order or `--sequence.shuffle --sequence.seed SEED_ID` to run a specific order) |
9898-| `--no-color` | Removes colors from the console output |
9999-| `--inspect [[host:]port]` | Enable Node.js inspector (default: 127.0.0.1:9229) |
100100-| `--inspect-brk [[host:]port]` | Enables Node.js inspector and break before the test starts |
101101-| `--bail <number>` | Stop test execution when given number of tests have failed |
102102-| `--retry <times>` | Retry the test specific number of times if it fails |
103103-| `--exclude <glob>` | Additional file globs to be excluded from test |
104104-| `--expand-snapshot-diff` | Show full diff when snapshot fails |
105105-| `--disable-console-intercept` | Disable automatic interception of console logging (default: `false`) |
106106-| `--clearScreen` | Clear terminal screen when re-running tests during watch mode (default: `true`) |
107107-| `--typecheck [options]` | Custom options for typecheck pool. If passed without options, enables typechecking |
108108-| `--typecheck.enabled` | Enable typechecking alongside tests (default: `false`) |
109109-| `--typecheck.only` | Run only typecheck tests. This automatically enables typecheck (default: `false`) |
110110-| `--project` | The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: `--project=1 --project=2`. You can also filter projects using wildcards like `--project=packages*` |
111111-| `-h, --help` | Display available CLI options |
6060+<!--@include: ./cli-table.md-->
1126111362::: tip
11463Vitest supports both camel case and kebab case for CLI arguments. For example, `--passWithNoTests` and `--pass-with-no-tests` will both work (`--no-color` and `--inspect-brk` are the exceptions).
+49
docs/.vitepress/scripts/cli-generator.ts
···11+import { writeFileSync } from 'node:fs'
22+import { dirname, resolve } from 'node:path'
33+import { fileURLToPath } from 'node:url'
44+import type { CLIOption, CLIOptions } from '../../../packages/vitest/src/node/cli/cli-config'
55+import { cliOptionsConfig } from '../../../packages/vitest/src/node/cli/cli-config'
66+77+const docsDir = resolve(dirname(fileURLToPath(import.meta.url)), '../..')
88+const cliTablePath = resolve(docsDir, './guide/cli-table.md')
99+1010+const nonNullable = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined
1111+1212+function resolveOptions(options: CLIOptions<any>, parentName?: string) {
1313+ return Object.entries(options).flatMap(
1414+ ([subcommandName, subcommandConfig]) => resolveCommand(
1515+ parentName ? `${parentName}.${subcommandName}` : subcommandName,
1616+ subcommandConfig,
1717+ ),
1818+ ).filter(nonNullable)
1919+}
2020+2121+function resolveCommand(name: string, config: CLIOption<any> | null): any {
2222+ if (!config)
2323+ return null
2424+2525+ let title = '`'
2626+ if (config.shorthand)
2727+ title += `-${config.shorthand}, `
2828+ title += `--${config.alias || name}`
2929+ if ('argument' in config)
3030+ title += ` ${config.argument}`
3131+ title += '`'
3232+ if ('subcommands' in config && config.subcommands)
3333+ return resolveOptions(config.subcommands)
3434+3535+ return {
3636+ title,
3737+ description: config.description,
3838+ }
3939+}
4040+4141+const options = resolveOptions(cliOptionsConfig)
4242+4343+const template = `
4444+| Options | |
4545+| ------------- | ------------- |
4646+${options.map(({ title, description }) => `| ${title} | ${description} |`).join('\n')}
4747+`.trimStart()
4848+4949+writeFileSync(cliTablePath, template, 'utf-8')
+4-4
packages/vitest/src/node/cli/cac.ts
···22import cac, { type CAC } from 'cac'
33import c from 'picocolors'
44import { version } from '../../../package.json'
55-import { toArray } from '../../utils'
55+import { toArray } from '../../utils/base'
66import type { Vitest, VitestRunMode } from '../../types'
77-import { divider } from '../reporters/renderers/utils'
87import type { CliOptions } from './cli-api'
99-import { startVitest } from './cli-api'
108import type { CLIOption } from './cli-config'
119import { cliOptionsConfig } from './cli-config'
1210···3533 const hasSubcommands = 'subcommands' in option && option.subcommands
36343735 if (option.description) {
3838- let description = option.description
3636+ let description = option.description.replace(/\[.*\]\((.*)\)/, '$1').replace(/`/g, '')
39374038 if (hasSubcommands)
4139 description += `. Use '--help --${commandName}' for more info.`
···242240 catch {}
243241244242 try {
243243+ const { startVitest } = await import('./cli-api')
245244 const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options))
246245 if (!ctx?.shouldKeepServer())
247246 await ctx?.exit()
248247 return ctx
249248 }
250249 catch (e) {
250250+ const { divider } = await import('../reporters/renderers/utils')
251251 console.error(`\n${c.red(divider(c.bold(c.inverse(' Unhandled Error '))))}`)
252252 console.error(e)
253253 console.error('\n\n')
+67-67
packages/vitest/src/node/cli/cli-config.ts
···2121// require argument for non-boolean options
2222(NonNullable<Value> extends boolean ? {} : { argument: string })
23232424-type CLIOptions<Config extends {}> = {
2424+export type CLIOptions<Config extends {}> = {
2525 [Key in keyof Config as NonNullable<Config[Key]> extends Function ? never : Key]-?: CLIOption<Config[Key]> | null
2626}
2727···29293030const apiConfig: (port: number) => CLIOptions<ApiConfig> = (port: number) => ({
3131 port: {
3232- description: `Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to ${port}`,
3232+ description: `Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to \`${port}\``,
3333 argument: '[port]',
3434 },
3535 host: {
3636- description: 'Specify which IP addresses the server should listen on. Set this to 0.0.0.0 or true to listen on all addresses, including LAN and public addresses',
3636+ description: 'Specify which IP addresses the server should listen on. Set this to `0.0.0.0` or `true` to listen on all addresses, including LAN and public addresses',
3737 argument: '[host]',
3838 },
3939 strictPort: {
···44444545const poolThreadsCommands: CLIOptions<ThreadsOptions & WorkerContextOptions> = {
4646 isolate: {
4747- description: 'Isolate tests in threads pool (default: true)',
4747+ description: 'Isolate tests in threads pool (default: `true`)',
4848 },
4949 singleThread: {
5050- description: 'Run tests inside a single thread (default: false)',
5050+ description: 'Run tests inside a single thread (default: `false`)',
5151 },
5252 maxThreads: {
5353 description: 'Maximum number of threads to run tests in',
···5858 argument: '<workers>',
5959 },
6060 useAtomics: {
6161- description: 'Use Atomics to synchronize threads. This can improve performance in some cases, but might cause segfault in older Node versions (default: false)',
6161+ description: 'Use Atomics to synchronize threads. This can improve performance in some cases, but might cause segfault in older Node versions (default: `false`)',
6262 },
6363 execArgv: null,
6464}
65656666const poolForksCommands: CLIOptions<ForksOptions & WorkerContextOptions> = {
6767 isolate: {
6868- description: 'Isolate tests in threads pool (default: true)',
6868+ description: 'Isolate tests in threads pool (default: `true`)',
6969 },
7070 singleFork: {
7171- description: 'Run tests inside a single child_process (default: false)',
7171+ description: 'Run tests inside a single child_process (default: `false`)',
7272 },
7373 maxForks: {
7474 description: 'Maximum number of processes to run tests in',
···128128 description: 'Enable UI',
129129 },
130130 open: {
131131- description: 'Open UI automatically (default: !process.env.CI)',
131131+ description: 'Open UI automatically (default: `!process.env.CI`)',
132132 },
133133 api: {
134134 argument: '[port]',
···167167 argument: '<name>',
168168 },
169169 enabled: {
170170- description: 'Enables coverage collection. Can be overridden using the --coverage CLI option (default: false)',
170170+ description: 'Enables coverage collection. Can be overridden using the `--coverage` CLI option (default: `false`)',
171171 },
172172 include: {
173173- description: 'Files included in coverage as glob patterns. May be specified more than once when using multiple patterns (default: **)',
173173+ description: 'Files included in coverage as glob patterns. May be specified more than once when using multiple patterns (default: `**`)',
174174 argument: '<pattern>',
175175 array: true,
176176 },
177177 exclude: {
178178- description: 'Files to be excluded in coverage. May be specified more than once when using multiple extensions (default: Visit https://vitest.dev/config/#coverage-exclude)',
178178+ description: 'Files to be excluded in coverage. May be specified more than once when using multiple extensions (default: Visit [`coverage.exclude`](https://vitest.dev/config/#coverage-exclude))',
179179 argument: '<pattern>',
180180 array: true,
181181 },
182182 extension: {
183183- description: 'Extension to be included in coverage. May be specified more than once when using multiple extensions (default: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"])',
183183+ description: 'Extension to be included in coverage. May be specified more than once when using multiple extensions (default: `[".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"]`)',
184184 argument: '<extension>',
185185 array: true,
186186 },
···196196 normalize: true,
197197 },
198198 reporter: {
199199- description: 'Coverage reporters to use. Visit https://vitest.dev/config/#coverage-reporter for more information (default: ["text", "html", "clover", "json"])',
199199+ description: 'Coverage reporters to use. Visit [`coverage.reporter`](https://vitest.dev/config/#coverage-reporter) for more information (default: `["text", "html", "clover", "json"]`)',
200200 argument: '<name>',
201201 subcommands: null, // don't support custom objects
202202 array: true,
···215215 argument: '', // no displayed
216216 subcommands: {
217217 perFile: {
218218- description: 'Check thresholds per file. See --coverage.thresholds.lines, --coverage.thresholds.functions, --coverage.thresholds.branches and --coverage.thresholds.statements for the actual thresholds (default: false)',
218218+ description: 'Check thresholds per file. See `--coverage.thresholds.lines`, `--coverage.thresholds.functions`, `--coverage.thresholds.branches` and `--coverage.thresholds.statements` for the actual thresholds (default: `false`)',
219219 },
220220 autoUpdate: {
221221- description: 'Update threshold values: "lines", "functions", "branches" and "statements" to configuration file when current coverage is above the configured thresholds (default: false)',
221221+ description: 'Update threshold values: "lines", "functions", "branches" and "statements" to configuration file when current coverage is above the configured thresholds (default: `false`)',
222222 },
223223 lines: {
224224- description: 'Threshold for lines. Visit https://github.com/istanbuljs/nyc#coverage-thresholds for more information. This option is not available for custom providers',
224224+ description: 'Threshold for lines. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers',
225225 argument: '<number>',
226226 },
227227 functions: {
228228- description: 'Threshold for functions. Visit https://github.com/istanbuljs/nyc#coverage-thresholds for more information. This option is not available for custom providers',
228228+ description: 'Threshold for functions. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers',
229229 argument: '<number>',
230230 },
231231 branches: {
232232- description: 'Threshold for branches. Visit https://github.com/istanbuljs/nyc#coverage-thresholds for more information. This option is not available for custom providers',
232232+ description: 'Threshold for branches. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers',
233233 argument: '<number>',
234234 },
235235 statements: {
236236- description: 'Threshold for statements. Visit https://github.com/istanbuljs/nyc#coverage-thresholds for more information. This option is not available for custom providers',
236236+ description: 'Threshold for statements. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers',
237237 argument: '<number>',
238238 },
239239 100: {
240240- description: 'Shortcut to set all coverage thresholds to 100 (default: false)',
240240+ description: 'Shortcut to set all coverage thresholds to 100 (default: `false`)',
241241 },
242242 },
243243 },
244244 ignoreClassMethods: {
245245- description: 'Array of class method names to ignore for coverage. Visit https://github.com/istanbuljs/nyc#ignoring-methods for more information. This option is only available for the istanbul providers (default: [])',
245245+ description: 'Array of class method names to ignore for coverage. Visit [istanbuljs](https://github.com/istanbuljs/nyc#ignoring-methods) for more information. This option is only available for the istanbul providers (default: `[]`)',
246246 argument: '<name>',
247247 array: true,
248248 },
···251251 argument: '<number>',
252252 },
253253 customProviderModule: {
254254- description: 'Specifies the module name or path for the custom coverage provider module. Visit https://vitest.dev/guide/coverage.html#custom-coverage-provider for more information. This option is only available for custom providers',
254254+ description: 'Specifies the module name or path for the custom coverage provider module. Visit [Custom Coverage Provider](https://vitest.dev/guide/coverage#custom-coverage-provider) for more information. This option is only available for custom providers',
255255 argument: '<path>',
256256 normalize: true,
257257 },
···260260 argument: '', // no displayed
261261 subcommands: {
262262 statements: {
263263- description: 'High and low watermarks for statements in the format of <high>,<low>',
263263+ description: 'High and low watermarks for statements in the format of `<high>,<low>`',
264264 argument: '<watermarks>',
265265 transform: watermarkTransform,
266266 },
267267 lines: {
268268- description: 'High and low watermarks for lines in the format of <high>,<low>',
268268+ description: 'High and low watermarks for lines in the format of `<high>,<low>`',
269269 argument: '<watermarks>',
270270 transform: watermarkTransform,
271271 },
272272 branches: {
273273- description: 'High and low watermarks for branches in the format of <high>,<low>',
273273+ description: 'High and low watermarks for branches in the format of `<high>,<low>`',
274274 argument: '<watermarks>',
275275 transform: watermarkTransform,
276276 },
277277 functions: {
278278- description: 'High and low watermarks for functions in the format of <high>,<low>',
278278+ description: 'High and low watermarks for functions in the format of `<high>,<low>`',
279279 argument: '<watermarks>',
280280 transform: watermarkTransform,
281281 },
···284284 },
285285 },
286286 mode: {
287287- description: 'Override Vite mode (default: test or benchmark)',
287287+ description: 'Override Vite mode (default: `test` or `benchmark`)',
288288 argument: '<name>',
289289 },
290290 workspace: {
···293293 normalize: true,
294294 },
295295 isolate: {
296296- description: 'Run every test file in isolation. To disable isolation, use --no-isolate (default: true)',
296296+ description: 'Run every test file in isolation. To disable isolation, use `--no-isolate` (default: `true`)',
297297 },
298298 globals: {
299299 description: 'Inject apis globally',
···302302 description: 'Mock browser API with happy-dom',
303303 },
304304 browser: {
305305- description: 'Run tests in the browser. Equivalent to --browser.enabled (default: false)',
305305+ description: 'Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)',
306306 argument: '<name>',
307307 transform(browser) {
308308 if (typeof browser === 'boolean')
···317317 },
318318 subcommands: {
319319 enabled: {
320320- description: 'Run tests in the browser. Equivalent to --browser.enabled (default: false)',
320320+ description: 'Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)',
321321 },
322322 name: {
323323- description: 'Run all tests in a specific browser. Some browsers are only available for specific providers (see --browser.provider). Visit https://vitest.dev/config/#browser-name for more information',
323323+ description: 'Run all tests in a specific browser. Some browsers are only available for specific providers (see `--browser.provider`). Visit [`browser.name`](https://vitest.dev/config/#browser-name) for more information',
324324 argument: '<name>',
325325 },
326326 headless: {
327327- description: 'Run the browser in headless mode (i.e. without opening the GUI (Graphical User Interface)). If you are running Vitest in CI, it will be enabled by default (default: process.env.CI)',
327327+ description: 'Run the browser in headless mode (i.e. without opening the GUI (Graphical User Interface)). If you are running Vitest in CI, it will be enabled by default (default: `process.env.CI`)',
328328 },
329329 api: {
330330 description: 'Specify options for the browser API server. Does not affect the --api option',
···332332 subcommands: apiConfig(defaultBrowserPort),
333333 },
334334 provider: {
335335- description: 'Provider used to run browser tests. Some browsers are only available for specific providers. Can be "webdriverio", "playwright", or the path to a custom provider. Visit https://vitest.dev/config/#browser-provider for more information (default: "webdriverio")',
335335+ description: 'Provider used to run browser tests. Some browsers are only available for specific providers. Can be "webdriverio", "playwright", or the path to a custom provider. Visit [`browser.provider`](https://vitest.dev/config/#browser-provider) for more information (default: `"webdriverio"`)',
336336 argument: '<name>',
337337 subcommands: null, // don't support custom objects
338338 },
339339 providerOptions: {
340340- description: 'Options that are passed down to a browser provider. Visit https://vitest.dev/config/#browser-provideroptions-1-0-0 for more information',
340340+ description: 'Options that are passed down to a browser provider. Visit [`browser.providerOptions`](https://vitest.dev/config/#browser-provideroptions) for more information',
341341 argument: '<options>',
342342 subcommands: null, // don't support custom objects
343343 },
344344 slowHijackESM: {
345345- description: 'Let Vitest use its own module resolution on the browser to enable APIs such as vi.mock and vi.spyOn. Visit https://vitest.dev/config/#browser-slowhijackesm for more information (default: false)',
345345+ description: 'Let Vitest use its own module resolution on the browser to enable APIs such as vi.mock and vi.spyOn. Visit [`browser.slowHijackESM`](https://vitest.dev/config/#browser-slowhijackesm) for more information (default: `false`)',
346346 },
347347 isolate: {
348348- description: 'Run every browser test file in isolation. To disable isolation, use --browser.isolate=false (default: true)',
348348+ description: 'Run every browser test file in isolation. To disable isolation, use `--browser.isolate=false` (default: `true`)',
349349 },
350350 fileParallelism: {
351351- description: 'Should all test files run in parallel. Use --browser.file-parallelism=false to disable (default: same as --file-parallelism)',
351351+ description: 'Should all test files run in parallel. Use `--browser.file-parallelism=false` to disable (default: same as `--file-parallelism`)',
352352 },
353353 },
354354 },
355355 pool: {
356356- description: 'Specify pool, if not running in the browser (default: threads)',
356356+ description: 'Specify pool, if not running in the browser (default: `threads`)',
357357 argument: '<pool>',
358358 subcommands: null, // don't support custom objects
359359 },
···398398 },
399399 },
400400 fileParallelism: {
401401- description: 'Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)',
401401+ description: 'Should all test files run in parallel. Use `--no-file-parallelism` to disable (default: `true`)',
402402 },
403403 maxWorkers: {
404404 description: 'Maximum number of workers to run tests in',
···409409 argument: '<workers>',
410410 },
411411 environment: {
412412- description: 'Specify runner environment, if not running in the browser (default: node)',
412412+ description: 'Specify runner environment, if not running in the browser (default: `node`)',
413413 argument: '<name>',
414414 subcommands: null, // don't support custom objects
415415 },
···420420 description: 'Show the size of heap for each test when running in node',
421421 },
422422 allowOnly: {
423423- description: 'Allow tests and suites that are marked as only (default: !process.env.CI)',
423423+ description: 'Allow tests and suites that are marked as only (default: `!process.env.CI`)',
424424 },
425425 dangerouslyIgnoreUnhandledErrors: {
426426 description: 'Ignore any unhandled errors that occur',
427427 },
428428 shard: {
429429- description: 'Test suite shard to execute in a format of <index>/<count>',
429429+ description: 'Test suite shard to execute in a format of `<index>/<count>`',
430430 argument: '<shards>',
431431 },
432432 changed: {
433433- description: 'Run tests that are affected by the changed files (default: false)',
433433+ description: 'Run tests that are affected by the changed files (default: `false`)',
434434 argument: '[since]',
435435 },
436436 sequence: {
···438438 argument: '<options>',
439439 subcommands: {
440440 shuffle: {
441441- description: 'Run files and tests in a random order. Enabling this option will impact Vitest\'s cache and have a performance impact. May be useful to find tests that accidentally depend on another run previously (default: false)',
441441+ description: 'Run files and tests in a random order. Enabling this option will impact Vitest\'s cache and have a performance impact. May be useful to find tests that accidentally depend on another run previously (default: `false`)',
442442 argument: '',
443443 subcommands: {
444444 files: {
445445- description: 'Run files in a random order. Long running tests will not start earlier if you enable this option. (default: false)',
445445+ description: 'Run files in a random order. Long running tests will not start earlier if you enable this option. (default: `false`)',
446446 },
447447 tests: {
448448- description: 'Run tests in a random oder (default: false)',
448448+ description: 'Run tests in a random oder (default: `false`)',
449449 },
450450 },
451451 },
452452 concurrent: {
453453- description: 'Make tests run in parallel (default: false)',
453453+ description: 'Make tests run in parallel (default: `false`)',
454454 },
455455 seed: {
456456- description: 'Set the randomization seed. This option will have no effect if --sequence.shuffle is falsy. Visit https://en.wikipedia.org/wiki/Random_seed for more information',
456456+ description: 'Set the randomization seed. This option will have no effect if --sequence.shuffle is falsy. Visit ["Random Seed" page](https://en.wikipedia.org/wiki/Random_seed) for more information',
457457 argument: '<seed>',
458458 },
459459 hooks: {
460460- description: 'Changes the order in which hooks are executed. Accepted values are: "stack", "list" and "parallel". Visit https://vitest.dev/config/#sequence-hooks for more information (default: "parallel")',
460460+ description: 'Changes the order in which hooks are executed. Accepted values are: "stack", "list" and "parallel". Visit [`sequence.hooks`](https://vitest.dev/config/#sequence-hooks) for more information (default: `"parallel"`)',
461461 argument: '<order>',
462462 },
463463 setupFiles: {
464464- description: 'Changes the order in which setup files are executed. Accepted values are: "list" and "parallel". If set to "list", will run setup files in the order they are defined. If set to "parallel", will run setup files in parallel (default: "parallel")',
464464+ description: 'Changes the order in which setup files are executed. Accepted values are: "list" and "parallel". If set to "list", will run setup files in the order they are defined. If set to "parallel", will run setup files in parallel (default: `"parallel"`)',
465465 argument: '<order>',
466466 },
467467 },
468468 },
469469 inspect: {
470470- description: 'Enable Node.js inspector (default: 127.0.0.1:9229)',
470470+ description: 'Enable Node.js inspector (default: `127.0.0.1:9229`)',
471471 argument: '[[host:]port]',
472472 transform(portOrEnabled) {
473473 if (portOrEnabled === 0 || portOrEnabled === 'true' || portOrEnabled === 'yes')
···490490 },
491491 inspector: null,
492492 testTimeout: {
493493- description: 'Default timeout of a test in milliseconds (default: 5000)',
493493+ description: 'Default timeout of a test in milliseconds (default: `5000`)',
494494 argument: '<timeout>',
495495 },
496496 hookTimeout: {
497497- description: 'Default hook timeout in milliseconds (default: 10000)',
497497+ description: 'Default hook timeout in milliseconds (default: `10000`)',
498498 argument: '<timeout>',
499499 },
500500 bail: {
501501- description: 'Stop test execution when given number of tests have failed (default: 0)',
501501+ description: 'Stop test execution when given number of tests have failed (default: `0`)',
502502 argument: '<number>',
503503 },
504504 retry: {
505505- description: 'Retry the test specific number of times if it fails (default: 0)',
505505+ description: 'Retry the test specific number of times if it fails (default: `0`)',
506506 argument: '<times>',
507507 },
508508 diff: {
···518518 description: 'Show full diff when snapshot fails',
519519 },
520520 disableConsoleIntercept: {
521521- description: 'Disable automatic interception of console logging (default: false)',
521521+ description: 'Disable automatic interception of console logging (default: `false`)',
522522 },
523523 typecheck: {
524524- description: 'Enable typechecking alongside tests (default: false)',
524524+ description: 'Enable typechecking alongside tests (default: `false`)',
525525 argument: '', // allow boolean
526526 transform: transformNestedBoolean,
527527 subcommands: {
528528 enabled: {
529529- description: 'Enable typechecking alongside tests (default: false)',
529529+ description: 'Enable typechecking alongside tests (default: `false`)',
530530 },
531531 only: {
532532- description: 'Run only typecheck tests. This automatically enables typecheck (default: false)',
532532+ description: 'Run only typecheck tests. This automatically enables typecheck (default: `false`)',
533533 },
534534 checker: {
535535- description: 'Specify the typechecker to use. Available values are: "tcs" and "vue-tsc" and a path to an executable (default: "tsc")',
535535+ description: 'Specify the typechecker to use. Available values are: "tcs" and "vue-tsc" and a path to an executable (default: `"tsc"`)',
536536 argument: '<name>',
537537 subcommands: null,
538538 },
···552552 },
553553 },
554554 project: {
555555- description: 'The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2. You can also filter projects using wildcards like --project=packages*',
555555+ description: 'The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: `--project=1 --project=2`. You can also filter projects using wildcards like `--project=packages*`',
556556 argument: '<name>',
557557 array: true,
558558 },
559559 slowTestThreshold: {
560560- description: 'Threshold in milliseconds for a test to be considered slow (default: 300)',
560560+ description: 'Threshold in milliseconds for a test to be considered slow (default: `300`)',
561561 argument: '<threshold>',
562562 },
563563 teardownTimeout: {
564564- description: 'Default timeout of a teardown function in milliseconds (default: 10000)',
564564+ description: 'Default timeout of a teardown function in milliseconds (default: `10000`)',
565565 argument: '<timeout>',
566566 },
567567 cache: {
···581581 },
582582 },
583583 maxConcurrency: {
584584- description: 'Maximum number of concurrent tests in a suite (default: 5)',
584584+ description: 'Maximum number of concurrent tests in a suite (default: `5`)',
585585 argument: '<number>',
586586 },
587587···590590 description: 'Disable watch mode',
591591 },
592592 segfaultRetry: {
593593- description: 'Retry the test suite if it crashes due to a segfault (default: true)',
593593+ description: 'Retry the test suite if it crashes due to a segfault (default: `true`)',
594594 argument: '<times>',
595595 default: 0,
596596 },
···599599 alias: 'no-color',
600600 },
601601 clearScreen: {
602602- description: 'Clear terminal screen when re-running tests during watch mode (default: true)',
602602+ description: 'Clear terminal screen when re-running tests during watch mode (default: `true`)',
603603 },
604604605605 // disable CLI options
···22import c from 'picocolors'
33import stripAnsi from 'strip-ansi'
44import type { SnapshotSummary, Task } from '../../../types'
55-import { slash } from '../../../utils'
55+import { slash } from '../../../utils/base'
66import { F_CHECK, F_CROSS, F_DOT, F_DOWN, F_DOWN_RIGHT, F_LONG_DASH, F_POINTER } from '../../../utils/figures'
77import type { SuiteHooks } from './../../../types/tasks'
88