Skip to content

Commit 4897b10

Browse files
Marve10swan9chi
andauthored
fix(cli): expose Vitest 5 options in test help (#2809)
`vp test --help` omits five top-level options accepted by the bundled Vitest 5, so users cannot discover them through the CLI. The static help list also still refers to `experimental.fsModuleCache` after that option moved to the top level. Add `--repeats`, `--injectCjsGlobals`, `--fsModuleCache`, `--fsModuleCachePath`, and `--sharedViteServer` with their upstream descriptions and defaults, and correct the `--clearCache` description. Update the recorded output for both help aliases. The change is limited to help text and its snapshots. Fixes #2804. --------- Co-authored-by: Charles Wang <me@wan9chi.com>
1 parent 688fe4a commit 4897b10

4 files changed

Lines changed: 65 additions & 47 deletions

File tree

‎crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_helper/snapshots/command_helper.md‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,16 @@ Options:
311311
--dir <path> Base directory to scan for the test files
312312
--ui Enable UI
313313
--open Open UI automatically (default: !process.env.CI)
314-
--api [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. Use '--help --api' for more info.
314+
--api [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 or 63315 in browser mode. Use '--help --api' for more info.
315315
--silent [value] Silent console output from tests. Use 'passed-only' to see logs from failing tests only.
316316
--hideSkippedTests Hide logs for skipped tests
317317
--reporter <name> Specify reporters (default, agent, minimal, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions)
318318
--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)
319319
--coverage Enable coverage report. Use '--help --coverage' for more info.
320-
--mode <name> Override Vite mode (default: test or benchmark)
320+
--mode <name> Override Vite mode (default: test)
321321
--isolate Run every test file in isolation. To disable isolation, use --no-isolate (default: true)
322322
--globals Inject apis globally
323+
--injectCjsGlobals Inject CommonJS variables (module, exports, require, __filename, __dirname) into every test module. To disable, use --no-inject-cjs-globals (default: true)
323324
--dom Mock browser API with happy-dom
324325
--browser <name> Run tests in the browser. Equivalent to --browser.enabled (default: false). Use '--help --browser' for more info.
325326
--pool <pool> Specify pool, if not running in the browser (default: forks)
@@ -342,40 +343,40 @@ Options:
342343
--hookTimeout <timeout> Default hook timeout in milliseconds (default: 10000). Use 0 to disable timeout completely.
343344
--bail <number> Stop test execution when given number of tests have failed (default: 0)
344345
--retry <times> Retry the test specific number of times if it fails (default: 0). Use '--help --retry' for more info.
346+
--repeats <number> Repeat every test a specific number of times regardless of the result (default: 0)
345347
--diff <path> DiffOptions object or a path to a module which exports DiffOptions object. Use '--help --diff' for more info.
346348
--exclude <glob> Additional file globs to be excluded from test
347349
--expandSnapshotDiff Show full diff when snapshot fails
348350
--disableConsoleIntercept Disable automatic interception of console logging (default: false)
349351
--typecheck Enable typechecking alongside tests (default: false). Use '--help --typecheck' for more info.
350-
--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*, and exclude projects with --project=!pattern.
352+
-p, --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*, and exclude projects with --project=!pattern. A project runs if it matches no negated pattern and, when regular patterns are also given, matches at least one of them.
351353
--slowTestThreshold <threshold> Threshold in milliseconds for a test or suite to be considered slow (default: 300)
352354
--teardownTimeout <timeout> Default timeout of a teardown function in milliseconds (default: 10000)
353355
--cache Enable cache. Use '--help --cache' for more info.
354356
--maxConcurrency <number> Maximum number of concurrent tests and suites during test file execution (default: 5)
357+
--fsModuleCache Cache transformed modules on the file system and reuse them between reruns (default: false)
358+
--fsModuleCachePath <path> Directory where the fsModuleCache is stored (default: node_modules/.vitest-cache)
355359
--expect Configuration options for expect() matches. Use '--help --expect' for more info.
356360
--printConsoleTrace Always print console stack traces
357361
--includeTaskLocation Collect test and suite locations in the location property
358-
--attachmentsDir <dir> The directory where attachments from context.annotate are stored in (default: .vitest-attachments)
362+
--attachmentsDir <dir> The directory where attachments from context.annotate are stored in (default: .vitest/attachments)
359363
--run Disable watch mode
360364
--no-color Removes colors from the console output (default: true)
361365
--clearScreen Clear terminal screen when re-running tests during watch mode (default: true)
362366
--standalone Start Vitest without running tests. Tests will be running only on change. If browser mode is enabled, the UI will be opened automatically. This option is ignored when CLI file filters are passed. (default: false)
363367
--mergeReports [path] Path to a blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests
364368
--listTags [type] List all available tags instead of running tests. --list-tags=json will output tags in JSON format, unless there are no tags.
365-
--clearCache Delete all Vitest caches, including experimental.fsModuleCache, without running any tests. This will reduce the performance in the subsequent test run.
369+
--clearCache Delete all Vitest caches, including the fsModuleCache, without running any tests. This will reduce the performance in the subsequent test run.
366370
--tagsFilter <expression> Run only tests with the specified tags. You can use logical operators && (and), || (or) and ! (not) to create complex expressions, see https://vitest.dev/guide/test-tags#syntax for more information.
367371
--strictTags Should Vitest throw an error if test has a tag that is not defined in the config. (default: true)
372+
--sharedViteServer Let inline projects that don't modify the Vite config reuse the Vite server of the config that declares them. (default: true)
368373
--experimental <features> Experimental features.. Use '--help --experimental' for more info.
369374
-h, --help Display this message
370375
371-
Bench Options:
372-
--compare <filename> Benchmark output file to compare against
373-
--outputJson <filename> Benchmark output file
374-
375376
List Options:
376377
--json [true/path] Print collected tests as JSON or write to a file (Default: false)
377378
--filesOnly Print only test files with out the test cases
378-
--staticParse Parse files statically instead of running them to collect tests (default: false)
379+
--staticParse Parse files statically instead of running them to collect tests (default: true)
379380
--staticParseConcurrency <limit> How many tests to process at the same time (default: os.availableParallelism())
380381
381382
Examples:

‎crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_tool_help/snapshots/command_tool_help.md‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,16 @@ Options:
144144
--dir <path> Base directory to scan for the test files
145145
--ui Enable UI
146146
--open Open UI automatically (default: !process.env.CI)
147-
--api [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. Use '--help --api' for more info.
147+
--api [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 or 63315 in browser mode. Use '--help --api' for more info.
148148
--silent [value] Silent console output from tests. Use 'passed-only' to see logs from failing tests only.
149149
--hideSkippedTests Hide logs for skipped tests
150150
--reporter <name> Specify reporters (default, agent, minimal, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions)
151151
--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)
152152
--coverage Enable coverage report. Use '--help --coverage' for more info.
153-
--mode <name> Override Vite mode (default: test or benchmark)
153+
--mode <name> Override Vite mode (default: test)
154154
--isolate Run every test file in isolation. To disable isolation, use --no-isolate (default: true)
155155
--globals Inject apis globally
156+
--injectCjsGlobals Inject CommonJS variables (module, exports, require, __filename, __dirname) into every test module. To disable, use --no-inject-cjs-globals (default: true)
156157
--dom Mock browser API with happy-dom
157158
--browser <name> Run tests in the browser. Equivalent to --browser.enabled (default: false). Use '--help --browser' for more info.
158159
--pool <pool> Specify pool, if not running in the browser (default: forks)
@@ -175,40 +176,40 @@ Options:
175176
--hookTimeout <timeout> Default hook timeout in milliseconds (default: 10000). Use 0 to disable timeout completely.
176177
--bail <number> Stop test execution when given number of tests have failed (default: 0)
177178
--retry <times> Retry the test specific number of times if it fails (default: 0). Use '--help --retry' for more info.
179+
--repeats <number> Repeat every test a specific number of times regardless of the result (default: 0)
178180
--diff <path> DiffOptions object or a path to a module which exports DiffOptions object. Use '--help --diff' for more info.
179181
--exclude <glob> Additional file globs to be excluded from test
180182
--expandSnapshotDiff Show full diff when snapshot fails
181183
--disableConsoleIntercept Disable automatic interception of console logging (default: false)
182184
--typecheck Enable typechecking alongside tests (default: false). Use '--help --typecheck' for more info.
183-
--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*, and exclude projects with --project=!pattern.
185+
-p, --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*, and exclude projects with --project=!pattern. A project runs if it matches no negated pattern and, when regular patterns are also given, matches at least one of them.
184186
--slowTestThreshold <threshold> Threshold in milliseconds for a test or suite to be considered slow (default: 300)
185187
--teardownTimeout <timeout> Default timeout of a teardown function in milliseconds (default: 10000)
186188
--cache Enable cache. Use '--help --cache' for more info.
187189
--maxConcurrency <number> Maximum number of concurrent tests and suites during test file execution (default: 5)
190+
--fsModuleCache Cache transformed modules on the file system and reuse them between reruns (default: false)
191+
--fsModuleCachePath <path> Directory where the fsModuleCache is stored (default: node_modules/.vitest-cache)
188192
--expect Configuration options for expect() matches. Use '--help --expect' for more info.
189193
--printConsoleTrace Always print console stack traces
190194
--includeTaskLocation Collect test and suite locations in the location property
191-
--attachmentsDir <dir> The directory where attachments from context.annotate are stored in (default: .vitest-attachments)
195+
--attachmentsDir <dir> The directory where attachments from context.annotate are stored in (default: .vitest/attachments)
192196
--run Disable watch mode
193197
--no-color Removes colors from the console output (default: true)
194198
--clearScreen Clear terminal screen when re-running tests during watch mode (default: true)
195199
--standalone Start Vitest without running tests. Tests will be running only on change. If browser mode is enabled, the UI will be opened automatically. This option is ignored when CLI file filters are passed. (default: false)
196200
--mergeReports [path] Path to a blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests
197201
--listTags [type] List all available tags instead of running tests. --list-tags=json will output tags in JSON format, unless there are no tags.
198-
--clearCache Delete all Vitest caches, including experimental.fsModuleCache, without running any tests. This will reduce the performance in the subsequent test run.
202+
--clearCache Delete all Vitest caches, including the fsModuleCache, without running any tests. This will reduce the performance in the subsequent test run.
199203
--tagsFilter <expression> Run only tests with the specified tags. You can use logical operators && (and), || (or) and ! (not) to create complex expressions, see https://vitest.dev/guide/test-tags#syntax for more information.
200204
--strictTags Should Vitest throw an error if test has a tag that is not defined in the config. (default: true)
205+
--sharedViteServer Let inline projects that don't modify the Vite config reuse the Vite server of the config that declares them. (default: true)
201206
--experimental <features> Experimental features.. Use '--help --experimental' for more info.
202207
-h, --help Display this message
203208
204-
Bench Options:
205-
--compare <filename> Benchmark output file to compare against
206-
--outputJson <filename> Benchmark output file
207-
208209
List Options:
209210
--json [true/path] Print collected tests as JSON or write to a file (Default: false)
210211
--filesOnly Print only test files with out the test cases
211-
--staticParse Parse files statically instead of running them to collect tests (default: false)
212+
--staticParse Parse files statically instead of running them to collect tests (default: true)
212213
--staticParseConcurrency <limit> How many tests to process at the same time (default: os.availableParallelism())
213214
214215
Examples:

0 commit comments

Comments
 (0)