From 4ace822421c1ac8929bd4c5f5ac166b6284db2c7 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 25 Nov 2026 21:33:37 +0800 Subject: [PATCH 1/3] fix(cli): guide rs test init users to manual browser setup --- packages/rstack/src/cli/commandHelp.ts | 12 ------------ packages/rstack/src/cli/commands.ts | 12 ++++++++++-- .../tests/cli/__snapshots__/help.test.ts.snap | 15 --------------- packages/rstack/tests/cli/help.test.ts | 10 +++++++++- website/docs/en/guide/cli/test.mdx | 8 -------- website/docs/zh/guide/cli/test.mdx | 8 -------- 6 files changed, 19 insertions(+), 46 deletions(-) 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..30eabf7f 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,15 @@ async function runRsbuildCLI(args: string[]): Promise { } async function runRstestCLI(args: string[]): Promise { + if (args[0] === 'init') { + logger.error( + 'Rstack does not support "rs test init". Configure browser tests manually with define.test() in rstack.config.ts.\n' + + 'See https://rstest.rs/guide/browser-testing/getting-started#manual-configuration', + ); + process.exitCode = 1; + return; + } + if (hasHelpFlag(args)) { switch (args[0]) { case 'run': @@ -41,8 +51,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..a39e3716 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()', + ); +}); 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/): From efefc7999fe102a1265e67ce39a063dd77eb3998 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 25 Nov 2026 21:36:06 +0800 Subject: [PATCH 2/3] fix(cli): simplify test init guidance --- packages/rstack/src/cli/commands.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/rstack/src/cli/commands.ts b/packages/rstack/src/cli/commands.ts index 30eabf7f..5dde35d7 100644 --- a/packages/rstack/src/cli/commands.ts +++ b/packages/rstack/src/cli/commands.ts @@ -34,8 +34,7 @@ async function runRsbuildCLI(args: string[]): Promise { async function runRstestCLI(args: string[]): Promise { if (args[0] === 'init') { logger.error( - 'Rstack does not support "rs test init". Configure browser tests manually with define.test() in rstack.config.ts.\n' + - 'See https://rstest.rs/guide/browser-testing/getting-started#manual-configuration', + 'Rstack CLI does not support "rs test init". Configure browser tests manually with define.test() in rstack.config.ts.', ); process.exitCode = 1; return; From 6c3aa23cc33caeafd4c4eb138381daa0508ddfe4 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 25 Nov 2026 21:38:49 +0800 Subject: [PATCH 3/3] fix(cli): avoid assuming a test config filename --- packages/rstack/src/cli/commands.ts | 2 +- packages/rstack/tests/cli/help.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rstack/src/cli/commands.ts b/packages/rstack/src/cli/commands.ts index 5dde35d7..f48927f5 100644 --- a/packages/rstack/src/cli/commands.ts +++ b/packages/rstack/src/cli/commands.ts @@ -34,7 +34,7 @@ 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 rstack.config.ts.', + 'Rstack CLI does not support "rs test init". Configure browser tests manually with `define.test()` in your Rstack config.', ); process.exitCode = 1; return; diff --git a/packages/rstack/tests/cli/help.test.ts b/packages/rstack/tests/cli/help.test.ts index a39e3716..747f4b73 100644 --- a/packages/rstack/tests/cli/help.test.ts +++ b/packages/rstack/tests/cli/help.test.ts @@ -59,6 +59,6 @@ test('directs test init users to manual browser setup', ({ expect, }) => { expect(() => execCli('test init browser')).toThrow( - 'Configure browser tests manually with define.test()', + 'Configure browser tests manually with `define.test()` in your Rstack config.', ); });