diff --git a/packages/rstack/src/cli/commandHelp.ts b/packages/rstack/src/cli/commandHelp.ts index 205654ae..1163e09a 100644 --- a/packages/rstack/src/cli/commandHelp.ts +++ b/packages/rstack/src/cli/commandHelp.ts @@ -37,7 +37,6 @@ export type HelpTopic = | 'test watch' | 'test list' | 'test merge-reports' - | 'test init' | 'lib' | 'lib build' | 'lib inspect' @@ -259,7 +258,6 @@ const HELP_DEFINITIONS = { ['watch [...filters]', 'Run tests in watch mode'], ['list [...filters]', 'List matching tests'], ['merge-reports [path]', 'Merge blob reports'], - ['init [project]', 'Initialize Rstest configuration'], ], }, commandHint('test'), @@ -338,16 +336,6 @@ const HELP_DEFINITIONS = { }, ], }, - 'test init': { - usage: 'rs test init [project] [options]', - description: 'Initialize Rstest configuration', - sections: [ - { - title: 'Options', - items: [['--yes', 'Use default options without prompts'], HELP_OPTION], - }, - ], - }, lib: { usage: 'rs lib [command] [options]', sections: [ diff --git a/packages/rstack/src/cli/commands.ts b/packages/rstack/src/cli/commands.ts index eca7fc08..f48927f5 100644 --- a/packages/rstack/src/cli/commands.ts +++ b/packages/rstack/src/cli/commands.ts @@ -1,5 +1,6 @@ import { join, resolve } from 'node:path'; import { pathToFileURL } from 'node:url'; +import { logger } from 'rslog'; import { CLI_CONFIG_PATH_ENV, getConfigState } from './config.ts'; import { insertConfigArg, parseArgs, parseCliArgs } from './args.ts'; import { hasHelpFlag, printCommandHelp } from './help.ts'; @@ -31,6 +32,14 @@ async function runRsbuildCLI(args: string[]): Promise { } async function runRstestCLI(args: string[]): Promise { + if (args[0] === 'init') { + logger.error( + 'Rstack CLI does not support "rs test init". Configure browser tests manually with `define.test()` in your Rstack config.', + ); + process.exitCode = 1; + return; + } + if (hasHelpFlag(args)) { switch (args[0]) { case 'run': @@ -41,8 +50,6 @@ async function runRstestCLI(args: string[]): Promise { return printCommandHelp('test list'); case 'merge-reports': return printCommandHelp('test merge-reports'); - case 'init': - return printCommandHelp('test init'); default: return printCommandHelp('test'); } diff --git a/packages/rstack/tests/cli/__snapshots__/help.test.ts.snap b/packages/rstack/tests/cli/__snapshots__/help.test.ts.snap index 65e3a481..9689b34e 100644 --- a/packages/rstack/tests/cli/__snapshots__/help.test.ts.snap +++ b/packages/rstack/tests/cli/__snapshots__/help.test.ts.snap @@ -226,7 +226,6 @@ Commands: watch [...filters] Run tests in watch mode list [...filters] List matching tests merge-reports [path] Merge blob reports - init [project] Initialize Rstest configuration For command-specific options, run: $ rs test -h @@ -242,20 +241,6 @@ Options: " `; -exports[`displays test init help 1`] = ` -"Rstack v - -Usage: - $ rs test init [project] [options] - -Initialize Rstest configuration - -Options: - --yes Use default options without prompts - -h, --help Display this help message -" -`; - exports[`displays test list help 1`] = ` "Rstack v diff --git a/packages/rstack/tests/cli/help.test.ts b/packages/rstack/tests/cli/help.test.ts index 09717ba0..747f4b73 100644 --- a/packages/rstack/tests/cli/help.test.ts +++ b/packages/rstack/tests/cli/help.test.ts @@ -45,7 +45,6 @@ for (const command of [ 'test watch', 'test list', 'test merge-reports', - 'test init', ]) { test(`displays ${command} help`, ({ execCli, expect }) => { const output = execCli(`${command} --help`); @@ -54,3 +53,12 @@ for (const command of [ expect(normalizeHelpOutput(output)).toMatchSnapshot(); }); } + +test('directs test init users to manual browser setup', ({ + execCli, + expect, +}) => { + expect(() => execCli('test init browser')).toThrow( + 'Configure browser tests manually with `define.test()` in your Rstack config.', + ); +}); diff --git a/website/docs/en/guide/cli/test.mdx b/website/docs/en/guide/cli/test.mdx index 2d9c6b8a..4337fa5f 100644 --- a/website/docs/en/guide/cli/test.mdx +++ b/website/docs/en/guide/cli/test.mdx @@ -67,14 +67,6 @@ rs test list rs test merge-reports ``` -### init - -[`rs test init`](https://rstest.rs/guide/basic/cli#rstest-init) initializes an Rstest configuration for a supported project type. - -```bash -rs test init browser -``` - ## Configuration Configure tests through [`define.test()`](../configuration#define-test) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rstest configuration](https://rstest.rs/config/): diff --git a/website/docs/zh/guide/cli/test.mdx b/website/docs/zh/guide/cli/test.mdx index 75dfb958..9c2f710b 100644 --- a/website/docs/zh/guide/cli/test.mdx +++ b/website/docs/zh/guide/cli/test.mdx @@ -67,14 +67,6 @@ rs test list rs test merge-reports ``` -### init - -[`rs test init`](https://rstest.rs/zh/guide/basic/cli#rstest-init) 用于为支持的项目类型初始化 Rstest 配置。 - -```bash -rs test init browser -``` - ## 配置 \{#configuration} 在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.test()`](../configuration#define-test) 配置测试。该 API 支持标准的 [Rstest 配置](https://rstest.rs/zh/config/):