diff --git a/packages/core/src/cli/commands.ts b/packages/core/src/cli/commands.ts index 3e0d781cb..145afaa2f 100644 --- a/packages/core/src/cli/commands.ts +++ b/packages/core/src/cli/commands.ts @@ -19,9 +19,9 @@ const applyCommonOptions = (cli: CAC) => { ) .option( '--config-loader ', - 'Specify the loader to load the config file, can be `jiti` or `native`', + 'Specify the loader to load the config file (auto | jiti | native)', { - default: 'jiti', + default: 'auto', }, ) .option( diff --git a/website/docs/en/guide/basic/cli.mdx b/website/docs/en/guide/basic/cli.mdx index afeee9a27..42714cde9 100644 --- a/website/docs/en/guide/basic/cli.mdx +++ b/website/docs/en/guide/basic/cli.mdx @@ -132,59 +132,59 @@ b.test.ts:9:3 > test b-2 Rstest CLI provides several common options that can be used with all commands: -| Flag | Description | -| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `-c, --config ` | Specify the configuration file, can be a relative or absolute path, see [Specify config file](/guide/basic/configure-rstest#specify-config-file) | -| `--config-loader ` | Specify the config loader, can be `jiti` or `native`, see [Rsbuild - Specify config loader](https://rsbuild.rs/guide/configuration/rsbuild#specify-config-loader) | -| `-r, --root ` | Specify the project root directory, see [root](/config/test/root) | -| `--globals` | Provide global APIs, see [globals](/config/test/globals) | -| `--isolate` | Run tests in an isolated environment, see [isolate](/config/test/isolate) | -| `--reporter ` | Specify the test reporter, see [reporters](/config/test/reporters) | -| `--exclude ` | Exclude files from test, see [exclude](/config/test/exclude) | -| `-u, --update` | Update snapshot files, see [update](/config/test/update) | -| `--coverage` | Enable code coverage collection, see [coverage](/config/test/coverage) | -| `--passWithNoTests` | Allows the test suite to pass when no files are found, see [passWithNoTests](/config/test/pass-with-no-tests) | -| `--printConsoleTrace` | Print console traces when calling any console method, see [printConsoleTrace](/config/test/print-console-trace) | -| `--project ` | Only run tests for the specified project, see [Filter by project name](/guide/basic/test-filter#filter-by-project-name) | -| `--disableConsoleIntercept` | Disable console intercept, see [disableConsoleIntercept](/config/test/disable-console-intercept) | -| `--slowTestThreshold ` | The number of milliseconds after which a test or suite is considered slow, see [slowTestThreshold](/config/test/slow-test-threshold) | -| `-t, --testNamePattern ` | Run only tests with a name that matches the regex, see [testNamePattern](/config/test/test-name-pattern) | -| `--testEnvironment ` | The environment that will be used for testing, see [testEnvironment](/config/test/test-environment) | -| `--testTimeout ` | Timeout of a test in milliseconds, see [testTimeout](/config/test/test-timeout) | -| `--hookTimeout ` | Timeout of hook in milliseconds, see [hookTimeout](/config/test/hook-timeout) | -| `--retry ` | Number of times to retry a test if it fails, see [retry](/config/test/retry) | -| `--bail [number]` | Abort the test run after the specified number of test failures, see [bail](/config/test/bail) | -| `--browser, --browser.enabled` | Run tests in Browser Mode, see [browser](/config/test/browser) | -| `--browser.name ` | Browser to use: `chromium`, `firefox`, `webkit` (default: `chromium`), see [browser](/config/test/browser) | -| `--browser.headless` | Run browser in headless mode (default: `true` in CI), see [browser](/config/test/browser) | -| `--browser.port ` | Port for the Browser Mode dev server, see [browser](/config/test/browser) | -| `--browser.strictPort` | Exit if the specified port is already in use, see [browser](/config/test/browser) | -| `--maxConcurrency ` | Maximum number of concurrent tests, see [maxConcurrency](/config/test/max-concurrency) | -| `--clearMocks` | Automatically clear mock calls, instances, contexts and results before every test, see [clearMocks](/config/test/clear-mocks) | -| `--resetMocks` | Automatically reset mock state before every test, see [resetMocks](/config/test/reset-mocks) | -| `--restoreMocks` | Automatically restore mock state and implementation before every test, see [restoreMocks](/config/test/restore-mocks) | -| `--unstubGlobals` | Restores all global variables that were changed with `rstest.stubGlobal` before every test, see [unstubGlobals](/config/test/unstub-globals) | -| `--unstubEnvs` | Restores all `process.env` values that were changed with `rstest.stubEnv` before every test, see [unstubEnvs](/config/test/unstub-envs) | -| `--include ` | Specify test file matching pattern, see [include](/config/test/include) | -| `--includeSource ` | Specify in-source testing file matching pattern, see [includeSource](/config/test/include-source) | -| `--logHeapUsage` | Print heap usage for each test, see [logHeapUsage](/config/test/log-heap-usage) | -| `--hideSkippedTests` | Do not display skipped test logs, see [hideSkippedTests](/config/test/hide-skipped-tests) | -| `--hideSkippedTestFiles` | Do not display skipped test file logs, see [hideSkippedTestFiles](/config/test/hide-skipped-test-files) | -| `--chaiConfig ` | Customize Chai configuration, see [chaiConfig](/config/test/chai-config) | -| `--env ` | Set environment variables, see [env](/config/test/env) | -| `--pool ` | Shorthand for `--pool.type`, see [pool](/config/test/pool) | -| `--pool.type ` | Specify the test pool type, see [pool](/config/test/pool) | -| `--pool.maxWorkers ` | Maximum number or percentage of workers, see [pool](/config/test/pool) | -| `--pool.minWorkers ` | Minimum number or percentage of workers, see [pool](/config/test/pool) | -| `--pool.execArgv ` | Additional Node.js execArgv for worker processes (repeatable), see [pool](/config/test/pool) | -| `--setupFiles ` | Specify setup files list, see [setupFiles](/config/test/setup-files) | -| `--snapshotFormat ` | Customize snapshot format, see [snapshotFormat](/config/test/snapshot-format) | -| `--resolveSnapshotPath` | Customize snapshot path resolution, see [resolveSnapshotPath](/config/test/resolve-snapshot-path) | -| `--onConsoleLog ` | Handle console logs, see [onConsoleLog](/config/test/on-console-log) | -| `--name ` | Set test suite name, see [name](/config/test/name) | -| `--projects ` | Configure multi-project testing, see [projects](/config/test/projects) | -| `-h, --help` | Display help for command | -| `-v, --version` | Display version | +| Flag | Description | +| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-c, --config ` | Specify the configuration file, can be a relative or absolute path, see [Specify config file](/guide/basic/configure-rstest#specify-config-file) | +| `--config-loader ` | Specify the config loader (`auto` \| `jiti` \| `native`), see [Rsbuild - Specify config loader](https://rsbuild.rs/guide/configuration/rsbuild#specify-config-loader) | +| `-r, --root ` | Specify the project root directory, see [root](/config/test/root) | +| `--globals` | Provide global APIs, see [globals](/config/test/globals) | +| `--isolate` | Run tests in an isolated environment, see [isolate](/config/test/isolate) | +| `--reporter ` | Specify the test reporter, see [reporters](/config/test/reporters) | +| `--exclude ` | Exclude files from test, see [exclude](/config/test/exclude) | +| `-u, --update` | Update snapshot files, see [update](/config/test/update) | +| `--coverage` | Enable code coverage collection, see [coverage](/config/test/coverage) | +| `--passWithNoTests` | Allows the test suite to pass when no files are found, see [passWithNoTests](/config/test/pass-with-no-tests) | +| `--printConsoleTrace` | Print console traces when calling any console method, see [printConsoleTrace](/config/test/print-console-trace) | +| `--project ` | Only run tests for the specified project, see [Filter by project name](/guide/basic/test-filter#filter-by-project-name) | +| `--disableConsoleIntercept` | Disable console intercept, see [disableConsoleIntercept](/config/test/disable-console-intercept) | +| `--slowTestThreshold ` | The number of milliseconds after which a test or suite is considered slow, see [slowTestThreshold](/config/test/slow-test-threshold) | +| `-t, --testNamePattern ` | Run only tests with a name that matches the regex, see [testNamePattern](/config/test/test-name-pattern) | +| `--testEnvironment ` | The environment that will be used for testing, see [testEnvironment](/config/test/test-environment) | +| `--testTimeout ` | Timeout of a test in milliseconds, see [testTimeout](/config/test/test-timeout) | +| `--hookTimeout ` | Timeout of hook in milliseconds, see [hookTimeout](/config/test/hook-timeout) | +| `--retry ` | Number of times to retry a test if it fails, see [retry](/config/test/retry) | +| `--bail [number]` | Abort the test run after the specified number of test failures, see [bail](/config/test/bail) | +| `--browser, --browser.enabled` | Run tests in Browser Mode, see [browser](/config/test/browser) | +| `--browser.name ` | Browser to use: `chromium`, `firefox`, `webkit` (default: `chromium`), see [browser](/config/test/browser) | +| `--browser.headless` | Run browser in headless mode (default: `true` in CI), see [browser](/config/test/browser) | +| `--browser.port ` | Port for the Browser Mode dev server, see [browser](/config/test/browser) | +| `--browser.strictPort` | Exit if the specified port is already in use, see [browser](/config/test/browser) | +| `--maxConcurrency ` | Maximum number of concurrent tests, see [maxConcurrency](/config/test/max-concurrency) | +| `--clearMocks` | Automatically clear mock calls, instances, contexts and results before every test, see [clearMocks](/config/test/clear-mocks) | +| `--resetMocks` | Automatically reset mock state before every test, see [resetMocks](/config/test/reset-mocks) | +| `--restoreMocks` | Automatically restore mock state and implementation before every test, see [restoreMocks](/config/test/restore-mocks) | +| `--unstubGlobals` | Restores all global variables that were changed with `rstest.stubGlobal` before every test, see [unstubGlobals](/config/test/unstub-globals) | +| `--unstubEnvs` | Restores all `process.env` values that were changed with `rstest.stubEnv` before every test, see [unstubEnvs](/config/test/unstub-envs) | +| `--include ` | Specify test file matching pattern, see [include](/config/test/include) | +| `--includeSource ` | Specify in-source testing file matching pattern, see [includeSource](/config/test/include-source) | +| `--logHeapUsage` | Print heap usage for each test, see [logHeapUsage](/config/test/log-heap-usage) | +| `--hideSkippedTests` | Do not display skipped test logs, see [hideSkippedTests](/config/test/hide-skipped-tests) | +| `--hideSkippedTestFiles` | Do not display skipped test file logs, see [hideSkippedTestFiles](/config/test/hide-skipped-test-files) | +| `--chaiConfig ` | Customize Chai configuration, see [chaiConfig](/config/test/chai-config) | +| `--env ` | Set environment variables, see [env](/config/test/env) | +| `--pool ` | Shorthand for `--pool.type`, see [pool](/config/test/pool) | +| `--pool.type ` | Specify the test pool type, see [pool](/config/test/pool) | +| `--pool.maxWorkers ` | Maximum number or percentage of workers, see [pool](/config/test/pool) | +| `--pool.minWorkers ` | Minimum number or percentage of workers, see [pool](/config/test/pool) | +| `--pool.execArgv ` | Additional Node.js execArgv for worker processes (repeatable), see [pool](/config/test/pool) | +| `--setupFiles ` | Specify setup files list, see [setupFiles](/config/test/setup-files) | +| `--snapshotFormat ` | Customize snapshot format, see [snapshotFormat](/config/test/snapshot-format) | +| `--resolveSnapshotPath` | Customize snapshot path resolution, see [resolveSnapshotPath](/config/test/resolve-snapshot-path) | +| `--onConsoleLog ` | Handle console logs, see [onConsoleLog](/config/test/on-console-log) | +| `--name ` | Set test suite name, see [name](/config/test/name) | +| `--projects ` | Configure multi-project testing, see [projects](/config/test/projects) | +| `-h, --help` | Display help for command | +| `-v, --version` | Display version | ### Boolean option negation diff --git a/website/docs/zh/guide/basic/cli.mdx b/website/docs/zh/guide/basic/cli.mdx index b14cfdc57..2392c21a6 100644 --- a/website/docs/zh/guide/basic/cli.mdx +++ b/website/docs/zh/guide/basic/cli.mdx @@ -132,59 +132,59 @@ b.test.ts:9:3 > test b-2 Rstest CLI 支持以下常用参数,所有命令均可使用: -| 参数 | 说明 | -| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -| `-c, --config ` | 指定配置文件路径(相对或绝对路径),详见 [指定配置文件](/guide/basic/configure-rstest#指定配置文件) | -| `--config-loader ` | 指定配置加载器,可选 `jiti` 或 `native`,详见 [Rsbuild - 指定加载方式](https://rsbuild.rs/guide/configuration/rsbuild#specify-config-loader) | -| `-r, --root ` | 指定项目根目录,详见 [root](/config/test/root) | -| `--globals` | 提供全局 API,详见 [globals](/config/test/globals) | -| `--isolate` | 在隔离环境中运行测试,详见 [isolate](/config/test/isolate) | -| `--exclude ` | 排除指定文件,详见 [exclude](/config/test/exclude) | -| `-u, --update` | 更新快照文件,详见 [update](/config/test/update) | -| `--coverage` | 启用代码覆盖率收集,详见 [coverage](/config/test/coverage) | -| `--passWithNoTests` | 当未找到测试文件时允许测试通过,详见 [passWithNoTests](/config/test/pass-with-no-tests) | -| `--printConsoleTrace` | 调用 console 方法时打印调用栈,详见 [printConsoleTrace](/config/test/print-console-trace) | -| `--project ` | 仅运行指定项目的测试,详见 [根据项目名称过滤](/guide/basic/test-filter#根据项目名称过滤) | -| `--disableConsoleIntercept` | 禁用 console 拦截,详见 [disableConsoleIntercept](/config/test/disable-console-intercept) | -| `--slowTestThreshold ` | 设置测试或套件被视为慢的阈值(毫秒),详见 [slowTestThreshold](/config/test/slow-test-threshold) | -| `-t, --testNamePattern ` | 仅运行名称匹配正则的测试,详见 [testNamePattern](/config/test/test-name-pattern) | -| `--testEnvironment ` | 指定测试环境,详见 [testEnvironment](/config/test/test-environment) | -| `--testTimeout ` | 设置单个测试的超时时间(毫秒),详见 [testTimeout](/config/test/test-timeout) | -| `--hookTimeout ` | 设置单个测试 hook 的超时时间(毫秒),详见 [hookTimeout](/config/test/hook-timeout) | -| `--retry ` | 测试失败时重试次数,详见 [retry](/config/test/retry) | -| `--bail [number]` | 指定个数的测试失败后停止运行,详见 [bail](/config/test/bail) | -| `--browser, --browser.enabled` | 在浏览器模式下运行测试,详见 [browser](/config/test/browser) | -| `--browser.name ` | 使用的浏览器:`chromium`、`firefox`、`webkit`(默认:`chromium`),详见 [browser](/config/test/browser) | -| `--browser.headless` | 在无头模式下运行浏览器(CI 环境默认:`true`),详见 [browser](/config/test/browser) | -| `--browser.port ` | 浏览器模式开发服务器的端口,详见 [browser](/config/test/browser) | -| `--browser.strictPort` | 如果指定端口已被占用则退出,详见 [browser](/config/test/browser) | -| `--reporter ` | 指定测试报告器,详见 [reporters](/config/test/reporters) | -| `--maxConcurrency ` | 最大并发测试数,详见 [maxConcurrency](/config/test/max-concurrency) | -| `--clearMocks` | 每个测试前自动清除 mock 调用、实例、上下文和结果,详见 [clearMocks](/config/test/clear-mocks) | -| `--resetMocks` | 每个测试前自动重置 mock 状态,详见 [resetMocks](/config/test/reset-mocks) | -| `--restoreMocks` | 每个测试前自动恢复 mock 状态和实现,详见 [restoreMocks](/config/test/restore-mocks) | -| `--unstubGlobals` | 每个测试前恢复被 `rstest.stubGlobal` 修改的全局变量,详见 [unstubGlobals](/config/test/unstub-globals) | -| `--unstubEnvs` | 每个测试前恢复被 `rstest.stubEnv` 修改的 `process.env`,详见 [unstubEnvs](/config/test/unstub-envs) | -| `--include ` | 指定测试文件匹配模式,详见 [include](/config/test/include) | -| `--includeSource ` | 指定源码内联测试文件匹配模式,详见 [includeSource](/config/test/include-source) | -| `--logHeapUsage` | 打印每个测试的堆内存使用情况,详见 [logHeapUsage](/config/test/log-heap-usage) | -| `--hideSkippedTests` | 不展示跳过测试的日志,详见 [hideSkippedTests](/config/test/hide-skipped-tests) | -| `--hideSkippedTestFiles` | 不展示跳过测试文件的日志,详见 [hideSkippedTestFiles](/config/test/hide-skipped-test-files) | -| `--chaiConfig ` | 自定义 Chai 配置,详见 [chaiConfig](/config/test/chai-config) | -| `--env ` | 设置环境变量,详见 [env](/config/test/env) | -| `--pool ` | `--pool.type` 的 shorthand,详见 [pool](/config/test/pool) | -| `--pool.type ` | 指定测试线程池类型,详见 [pool](/config/test/pool) | -| `--pool.maxWorkers ` | 最大 worker 数量或百分比,详见 [pool](/config/test/pool) | -| `--pool.minWorkers ` | 最小 worker 数量或百分比,详见 [pool](/config/test/pool) | -| `--pool.execArgv ` | 传给 worker 进程的额外 Node.js execArgv(可重复传入),详见 [pool](/config/test/pool) | -| `--setupFiles ` | 指定 setup 文件列表,详见 [setupFiles](/config/test/setup-files) | -| `--snapshotFormat ` | 自定义快照格式,详见 [snapshotFormat](/config/test/snapshot-format) | -| `--resolveSnapshotPath` | 自定义快照路径解析,详见 [resolveSnapshotPath](/config/test/resolve-snapshot-path) | -| `--onConsoleLog ` | 处理 console 日志,详见 [onConsoleLog](/config/test/on-console-log) | -| `--name ` | 设置测试套件名称,详见 [name](/config/test/name) | -| `--projects ` | 配置多项目测试,详见 [projects](/config/test/projects) | -| `-h, --help` | 显示帮助信息 | -| `-v, --version` | 显示版本号 | +| 参数 | 说明 | +| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-c, --config ` | 指定配置文件路径(相对或绝对路径),详见 [指定配置文件](/guide/basic/configure-rstest#指定配置文件) | +| `--config-loader ` | 指定配置加载器 (`auto` \| `jiti` \| `native`),详见 [Rsbuild - 指定加载方式](https://rsbuild.rs/guide/configuration/rsbuild#specify-config-loader) | +| `-r, --root ` | 指定项目根目录,详见 [root](/config/test/root) | +| `--globals` | 提供全局 API,详见 [globals](/config/test/globals) | +| `--isolate` | 在隔离环境中运行测试,详见 [isolate](/config/test/isolate) | +| `--exclude ` | 排除指定文件,详见 [exclude](/config/test/exclude) | +| `-u, --update` | 更新快照文件,详见 [update](/config/test/update) | +| `--coverage` | 启用代码覆盖率收集,详见 [coverage](/config/test/coverage) | +| `--passWithNoTests` | 当未找到测试文件时允许测试通过,详见 [passWithNoTests](/config/test/pass-with-no-tests) | +| `--printConsoleTrace` | 调用 console 方法时打印调用栈,详见 [printConsoleTrace](/config/test/print-console-trace) | +| `--project ` | 仅运行指定项目的测试,详见 [根据项目名称过滤](/guide/basic/test-filter#根据项目名称过滤) | +| `--disableConsoleIntercept` | 禁用 console 拦截,详见 [disableConsoleIntercept](/config/test/disable-console-intercept) | +| `--slowTestThreshold ` | 设置测试或套件被视为慢的阈值(毫秒),详见 [slowTestThreshold](/config/test/slow-test-threshold) | +| `-t, --testNamePattern ` | 仅运行名称匹配正则的测试,详见 [testNamePattern](/config/test/test-name-pattern) | +| `--testEnvironment ` | 指定测试环境,详见 [testEnvironment](/config/test/test-environment) | +| `--testTimeout ` | 设置单个测试的超时时间(毫秒),详见 [testTimeout](/config/test/test-timeout) | +| `--hookTimeout ` | 设置单个测试 hook 的超时时间(毫秒),详见 [hookTimeout](/config/test/hook-timeout) | +| `--retry ` | 测试失败时重试次数,详见 [retry](/config/test/retry) | +| `--bail [number]` | 指定个数的测试失败后停止运行,详见 [bail](/config/test/bail) | +| `--browser, --browser.enabled` | 在浏览器模式下运行测试,详见 [browser](/config/test/browser) | +| `--browser.name ` | 使用的浏览器:`chromium`、`firefox`、`webkit`(默认:`chromium`),详见 [browser](/config/test/browser) | +| `--browser.headless` | 在无头模式下运行浏览器(CI 环境默认:`true`),详见 [browser](/config/test/browser) | +| `--browser.port ` | 浏览器模式开发服务器的端口,详见 [browser](/config/test/browser) | +| `--browser.strictPort` | 如果指定端口已被占用则退出,详见 [browser](/config/test/browser) | +| `--reporter ` | 指定测试报告器,详见 [reporters](/config/test/reporters) | +| `--maxConcurrency ` | 最大并发测试数,详见 [maxConcurrency](/config/test/max-concurrency) | +| `--clearMocks` | 每个测试前自动清除 mock 调用、实例、上下文和结果,详见 [clearMocks](/config/test/clear-mocks) | +| `--resetMocks` | 每个测试前自动重置 mock 状态,详见 [resetMocks](/config/test/reset-mocks) | +| `--restoreMocks` | 每个测试前自动恢复 mock 状态和实现,详见 [restoreMocks](/config/test/restore-mocks) | +| `--unstubGlobals` | 每个测试前恢复被 `rstest.stubGlobal` 修改的全局变量,详见 [unstubGlobals](/config/test/unstub-globals) | +| `--unstubEnvs` | 每个测试前恢复被 `rstest.stubEnv` 修改的 `process.env`,详见 [unstubEnvs](/config/test/unstub-envs) | +| `--include ` | 指定测试文件匹配模式,详见 [include](/config/test/include) | +| `--includeSource ` | 指定源码内联测试文件匹配模式,详见 [includeSource](/config/test/include-source) | +| `--logHeapUsage` | 打印每个测试的堆内存使用情况,详见 [logHeapUsage](/config/test/log-heap-usage) | +| `--hideSkippedTests` | 不展示跳过测试的日志,详见 [hideSkippedTests](/config/test/hide-skipped-tests) | +| `--hideSkippedTestFiles` | 不展示跳过测试文件的日志,详见 [hideSkippedTestFiles](/config/test/hide-skipped-test-files) | +| `--chaiConfig ` | 自定义 Chai 配置,详见 [chaiConfig](/config/test/chai-config) | +| `--env ` | 设置环境变量,详见 [env](/config/test/env) | +| `--pool ` | `--pool.type` 的 shorthand,详见 [pool](/config/test/pool) | +| `--pool.type ` | 指定测试线程池类型,详见 [pool](/config/test/pool) | +| `--pool.maxWorkers ` | 最大 worker 数量或百分比,详见 [pool](/config/test/pool) | +| `--pool.minWorkers ` | 最小 worker 数量或百分比,详见 [pool](/config/test/pool) | +| `--pool.execArgv ` | 传给 worker 进程的额外 Node.js execArgv(可重复传入),详见 [pool](/config/test/pool) | +| `--setupFiles ` | 指定 setup 文件列表,详见 [setupFiles](/config/test/setup-files) | +| `--snapshotFormat ` | 自定义快照格式,详见 [snapshotFormat](/config/test/snapshot-format) | +| `--resolveSnapshotPath` | 自定义快照路径解析,详见 [resolveSnapshotPath](/config/test/resolve-snapshot-path) | +| `--onConsoleLog ` | 处理 console 日志,详见 [onConsoleLog](/config/test/on-console-log) | +| `--name ` | 设置测试套件名称,详见 [name](/config/test/name) | +| `--projects ` | 配置多项目测试,详见 [projects](/config/test/projects) | +| `-h, --help` | 显示帮助信息 | +| `-v, --version` | 显示版本号 | ### 布尔选项取反