Skip to content

Commit 1b6c685

Browse files
authored
fix(cli): guide rs test init users to manual browser setup (#667)
1 parent 59b861e commit 1b6c685

6 files changed

Lines changed: 18 additions & 46 deletions

File tree

‎packages/rstack/src/cli/commandHelp.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export type HelpTopic =
3737
| 'test watch'
3838
| 'test list'
3939
| 'test merge-reports'
40-
| 'test init'
4140
| 'lib'
4241
| 'lib build'
4342
| 'lib inspect'
@@ -259,7 +258,6 @@ const HELP_DEFINITIONS = {
259258
['watch [...filters]', 'Run tests in watch mode'],
260259
['list [...filters]', 'List matching tests'],
261260
['merge-reports [path]', 'Merge blob reports'],
262-
['init [project]', 'Initialize Rstest configuration'],
263261
],
264262
},
265263
commandHint('test'),
@@ -338,16 +336,6 @@ const HELP_DEFINITIONS = {
338336
},
339337
],
340338
},
341-
'test init': {
342-
usage: 'rs test init [project] [options]',
343-
description: 'Initialize Rstest configuration',
344-
sections: [
345-
{
346-
title: 'Options',
347-
items: [['--yes', 'Use default options without prompts'], HELP_OPTION],
348-
},
349-
],
350-
},
351339
lib: {
352340
usage: 'rs lib [command] [options]',
353341
sections: [

‎packages/rstack/src/cli/commands.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { join, resolve } from 'node:path';
22
import { pathToFileURL } from 'node:url';
3+
import { logger } from 'rslog';
34
import { CLI_CONFIG_PATH_ENV, getConfigState } from './config.ts';
45
import { insertConfigArg, parseArgs, parseCliArgs } from './args.ts';
56
import { hasHelpFlag, printCommandHelp } from './help.ts';
@@ -31,6 +32,14 @@ async function runRsbuildCLI(args: string[]): Promise<void> {
3132
}
3233

3334
async function runRstestCLI(args: string[]): Promise<void> {
35+
if (args[0] === 'init') {
36+
logger.error(
37+
'Rstack CLI does not support "rs test init". Configure browser tests manually with `define.test()` in your Rstack config.',
38+
);
39+
process.exitCode = 1;
40+
return;
41+
}
42+
3443
if (hasHelpFlag(args)) {
3544
switch (args[0]) {
3645
case 'run':
@@ -41,8 +50,6 @@ async function runRstestCLI(args: string[]): Promise<void> {
4150
return printCommandHelp('test list');
4251
case 'merge-reports':
4352
return printCommandHelp('test merge-reports');
44-
case 'init':
45-
return printCommandHelp('test init');
4653
default:
4754
return printCommandHelp('test');
4855
}

‎packages/rstack/tests/cli/__snapshots__/help.test.ts.snap‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ Commands:
226226
watch [...filters] Run tests in watch mode
227227
list [...filters] List matching tests
228228
merge-reports [path] Merge blob reports
229-
init [project] Initialize Rstest configuration
230229
231230
For command-specific options, run:
232231
$ rs test <command> -h
@@ -242,20 +241,6 @@ Options:
242241
"
243242
`;
244243
245-
exports[`displays test init help 1`] = `
246-
"Rstack v<version>
247-
248-
Usage:
249-
$ rs test init [project] [options]
250-
251-
Initialize Rstest configuration
252-
253-
Options:
254-
--yes Use default options without prompts
255-
-h, --help Display this help message
256-
"
257-
`;
258-
259244
exports[`displays test list help 1`] = `
260245
"Rstack v<version>
261246

‎packages/rstack/tests/cli/help.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ for (const command of [
4545
'test watch',
4646
'test list',
4747
'test merge-reports',
48-
'test init',
4948
]) {
5049
test(`displays ${command} help`, ({ execCli, expect }) => {
5150
const output = execCli(`${command} --help`);
@@ -54,3 +53,12 @@ for (const command of [
5453
expect(normalizeHelpOutput(output)).toMatchSnapshot();
5554
});
5655
}
56+
57+
test('directs test init users to manual browser setup', ({
58+
execCli,
59+
expect,
60+
}) => {
61+
expect(() => execCli('test init browser')).toThrow(
62+
'Configure browser tests manually with `define.test()` in your Rstack config.',
63+
);
64+
});

‎website/docs/en/guide/cli/test.mdx‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ rs test list
6767
rs test merge-reports
6868
```
6969

70-
### init
71-
72-
[`rs test init`](https://rstest.rs/guide/basic/cli#rstest-init) initializes an Rstest configuration for a supported project type.
73-
74-
```bash
75-
rs test init browser
76-
```
77-
7870
## Configuration
7971

8072
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/):

‎website/docs/zh/guide/cli/test.mdx‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ rs test list
6767
rs test merge-reports
6868
```
6969

70-
### init
71-
72-
[`rs test init`](https://rstest.rs/zh/guide/basic/cli#rstest-init) 用于为支持的项目类型初始化 Rstest 配置。
73-
74-
```bash
75-
rs test init browser
76-
```
77-
7870
## 配置 \{#configuration}
7971

8072
在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.test()`](../configuration#define-test) 配置测试。该 API 支持标准的 [Rstest 配置](https://rstest.rs/zh/config/):

0 commit comments

Comments
 (0)