@@ -110,6 +110,139 @@ const renderPreviewHelp = (): string =>
110110 ] ,
111111 } ) ;
112112
113+ const renderTestHelp = ( ) : string =>
114+ renderHelp ( {
115+ usage : 'rs test [command] [...filters] [options]' ,
116+ sections : [
117+ {
118+ title : 'Commands' ,
119+ items : [
120+ [ '[...filters]' , 'Run tests (default)' ] ,
121+ [ 'run [...filters]' , 'Run tests once' ] ,
122+ [ 'watch [...filters]' , 'Run tests in watch mode' ] ,
123+ [ 'list [...filters]' , 'List matching tests' ] ,
124+ [ 'merge-reports [path]' , 'Merge blob reports' ] ,
125+ [ 'init [project]' , 'Initialize Rstest configuration' ] ,
126+ ] ,
127+ } ,
128+ {
129+ content : `For command-specific options, run:
130+ $ rs test <command> -h` ,
131+ dim : true ,
132+ } ,
133+ {
134+ title : 'Options' ,
135+ items : [
136+ [ '-w, --watch' , 'Enable watch mode' ] ,
137+ [ '-u, --update' , 'Update snapshot files' ] ,
138+ [ '--coverage' , 'Enable code coverage' ] ,
139+ [ '--project <name>' , 'Filter test projects by name' ] ,
140+ [ '-t, --test-name-pattern <pattern>' , 'Run tests with names matching the pattern' ] ,
141+ [ '-c, --config <path>' , 'Specify Rstack config file path' ] ,
142+ [ '-h, --help' , 'Display this help message' ] ,
143+ ] ,
144+ } ,
145+ ] ,
146+ } ) ;
147+
148+ const renderTestRunHelp = ( ) : string =>
149+ renderHelp ( {
150+ usage : 'rs test run [...filters] [options]' ,
151+ description : 'Run tests once' ,
152+ sections : [
153+ {
154+ title : 'Options' ,
155+ items : [
156+ [ '--related' , 'Run tests related to source files' ] ,
157+ [ '--changed [commit]' , 'Run tests related to changed files' ] ,
158+ [ '--shard <index/count>' , 'Split tests into shards' ] ,
159+ [ '-u, --update' , 'Update snapshot files' ] ,
160+ [ '--coverage' , 'Enable code coverage' ] ,
161+ [ '--project <name>' , 'Filter test projects by name' ] ,
162+ [ '-t, --test-name-pattern <pattern>' , 'Run tests with names matching the pattern' ] ,
163+ [ '-c, --config <path>' , 'Specify Rstack config file path' ] ,
164+ [ '-h, --help' , 'Display this help message' ] ,
165+ ] ,
166+ } ,
167+ ] ,
168+ } ) ;
169+
170+ const renderTestWatchHelp = ( ) : string =>
171+ renderHelp ( {
172+ usage : 'rs test watch [...filters] [options]' ,
173+ description : 'Run tests in watch mode' ,
174+ sections : [
175+ {
176+ title : 'Options' ,
177+ items : [
178+ [ '-u, --update' , 'Update snapshot files' ] ,
179+ [ '--coverage' , 'Enable code coverage' ] ,
180+ [ '--project <name>' , 'Filter test projects by name' ] ,
181+ [ '-t, --test-name-pattern <pattern>' , 'Run tests with names matching the pattern' ] ,
182+ [ '-c, --config <path>' , 'Specify Rstack config file path' ] ,
183+ [ '-h, --help' , 'Display this help message' ] ,
184+ ] ,
185+ } ,
186+ ] ,
187+ } ) ;
188+
189+ const renderTestListHelp = ( ) : string =>
190+ renderHelp ( {
191+ usage : 'rs test list [...filters] [options]' ,
192+ description : 'List matching tests' ,
193+ sections : [
194+ {
195+ title : 'Options' ,
196+ items : [
197+ [ '--related' , 'List tests related to source files' ] ,
198+ [ '--changed [commit]' , 'List tests related to changed files' ] ,
199+ [ '--files-only' , 'List matching test files only' ] ,
200+ [ '--json [path]' , 'Print JSON or write it to a file' ] ,
201+ [ '--include-suites' , 'Include test suites' ] ,
202+ [ '--print-location' , 'Print test locations' ] ,
203+ [ '--summary' , 'Print a summary' ] ,
204+ [ '--project <name>' , 'Filter test projects by name' ] ,
205+ [ '-t, --test-name-pattern <pattern>' , 'List tests with names matching the pattern' ] ,
206+ [ '-c, --config <path>' , 'Specify Rstack config file path' ] ,
207+ [ '-h, --help' , 'Display this help message' ] ,
208+ ] ,
209+ } ,
210+ ] ,
211+ } ) ;
212+
213+ const renderTestMergeReportsHelp = ( ) : string =>
214+ renderHelp ( {
215+ usage : 'rs test merge-reports [path] [options]' ,
216+ description : 'Merge blob reports' ,
217+ sections : [
218+ {
219+ title : 'Options' ,
220+ items : [
221+ [ '--coverage' , 'Generate coverage reports' ] ,
222+ [ '--reporters, --reporter <name>' , 'Specify test reporters' ] ,
223+ [ '--cleanup' , 'Remove blob reports after merging' ] ,
224+ [ '-c, --config <path>' , 'Specify Rstack config file path' ] ,
225+ [ '-h, --help' , 'Display this help message' ] ,
226+ ] ,
227+ } ,
228+ ] ,
229+ } ) ;
230+
231+ const renderTestInitHelp = ( ) : string =>
232+ renderHelp ( {
233+ usage : 'rs test init [project] [options]' ,
234+ description : 'Initialize Rstest configuration' ,
235+ sections : [
236+ {
237+ title : 'Options' ,
238+ items : [
239+ [ '--yes' , 'Use default options without prompts' ] ,
240+ [ '-h, --help' , 'Display this help message' ] ,
241+ ] ,
242+ } ,
243+ ] ,
244+ } ) ;
245+
113246const renderLibHelp = ( ) : string =>
114247 renderHelp ( {
115248 usage : 'rs lib [command] [options]' ,
@@ -214,6 +347,29 @@ async function runRsbuildCLI(args: string[]): Promise<void> {
214347}
215348
216349async function runRstestCLI ( args : string [ ] ) : Promise < void > {
350+ if ( hasHelpFlag ( args ) ) {
351+ switch ( args [ 0 ] ) {
352+ case 'run' :
353+ console . log ( renderTestRunHelp ( ) ) ;
354+ return ;
355+ case 'watch' :
356+ console . log ( renderTestWatchHelp ( ) ) ;
357+ return ;
358+ case 'list' :
359+ console . log ( renderTestListHelp ( ) ) ;
360+ return ;
361+ case 'merge-reports' :
362+ console . log ( renderTestMergeReportsHelp ( ) ) ;
363+ return ;
364+ case 'init' :
365+ console . log ( renderTestInitHelp ( ) ) ;
366+ return ;
367+ default :
368+ console . log ( renderTestHelp ( ) ) ;
369+ return ;
370+ }
371+ }
372+
217373 const argv = [
218374 process . execPath ,
219375 'rstest' ,
0 commit comments