CLI
Rstest comes with a lightweight CLI that includes commands such as rstest watch and rstest run.
rstest -h
rstest -h can help you view all available CLI commands and options:
The output is shown below:
Use npx rstest <command> -h to see command-specific options. For example, npx rstest init -h only shows initialization options, while npx rstest merge-reports -h only shows merge-related options.
rstest [...filters]
Running rstest directly will enable the Rstest test in the current directory.
Watch mode
If you want to automatically rerun the test when the file changes, you can use the --watch flag or rstest watch command:
rstest run
rstest run will perform a single run, and the command is suitable for CI environments or scenarios where tests are not required to be performed while modifying.
rstest watch
rstest watch will start listening mode and execute tests, and when the test or dependent file modifications, the associated test file will be re-execute.
rstest list
rstest list will print a test list of all matching conditions. By default, it prints the test names of all matching tests.
The rstest list command inherits all rstest filtering options, you can filter files directly or use -t to filter the specified test name.
You can use --filesOnly to make it print the test files only:
You can use --json to make it print tests in JSON format in terminal or save the results to a separate file:
You can use --includeSuites to print test suites along side test cases:
You can use --printLocation to print location of tests:
You can use --summary to append a compact summary after the list output:
When used with --json, --summary changes the JSON output shape from an array to an object with items and summary fields.
rstest merge-reports
rstest merge-reports merges blob reports generated by multiple test shards into a single unified report. This is useful when running tests in parallel across multiple CI machines using --shard.
Workflow
- Run each shard with the
blobreporter to generate blob report files:
- Collect all
.rstest-reports/directories into a single location, then merge:
By default, blob reports are read from .rstest-reports/ in the project root. You can specify a custom path:
The merge command will:
- Combine test results from all shards
- Run configured reporters (e.g.,
default,junit) with the merged data - Merge and generate coverage reports (if coverage is enabled)
Use --cleanup to remove the blob reports directory after merging:
rstest init
rstest init creates starter configuration for supported project types.
Currently, browser is the available initializer:
Use --yes to skip the interactive prompt and apply the default setup:
CLI options
Rstest CLI options are registered per command instead of being shared by every command.
Test commands
rstest, rstest run, and rstest watch share the same test runtime options:
rstest also supports -w, --watch, which switches the default command into watch mode.
rstest list
rstest list supports the same filtering and config options as the test commands above, and adds:
rstest merge-reports
rstest merge-reports has its own smaller option set:
rstest init
rstest init only accepts initialization-specific options:
Boolean option negation
For boolean options, you can use the --no-<option> prefix to set them to false. For example:
CLI shortcuts
When running Rstest in watch mode, you can use keyboard shortcuts to perform various actions.
All shortcuts:
CLI shortcuts are only available when running Rstest in watch mode (rstest watch or rstest --watch) and when the terminal supports TTY (interactive mode).