CI
Rstest uses the same CLI in CI as it does locally. The main difference is that CI should run tests in run mode with rstest, then upload any reports that other tools need to read.
Basic workflow
Use rstest in CI so the process exits after one test pass. If your project already has a test script, keep CI calling that script and make the script run rstest.
A minimal GitHub Actions workflow installs dependencies, restores the package-manager cache, and runs the test script:
When Rstest detects GitHub Actions and no reporter is manually configured, it automatically enables the github-actions reporter. Failed assertions are turned into GitHub annotations, and a Markdown summary is appended to the workflow summary. See reporters for reporter details.
Other CI systems can use the same commands. The important part is to run pnpm install --frozen-lockfile before pnpm rstest or your package script.
Add coverage
Coverage collection is opt-in. Install the provider you want to use before enabling --coverage:
- @rstest/coverage-istanbul: the default Istanbul provider, works in Node mode and Browser Mode.
- @rstest/coverage-v8: V8-based provider for Node mode only.
Upload the generated coverage/ directory if your CI needs to keep the HTML report or pass coverage data to another service:
Use if: always() when the report is useful for failed runs too. For available providers, reporters, thresholds, and output paths, see coverage.
Browser mode in CI
Browser Mode runs tests in a real browser, so CI must install both the Rstest browser package and the browser binaries. Install @rstest/browser in the project, then install the Playwright browser used by your config.
In CI, browser.headless defaults to true, so the browser runs without a visible window. A GitHub Actions workflow usually adds the browser installation step before running tests:
If you test with firefox or webkit, install the same browser that browser.browser selects. See Browser Mode getting started and browser configuration for full setup options.
Split tests with shards
Use --shard <index>/<count> when the full suite is stable but too slow for one CI machine. Each shard runs a different subset of test files. To combine results and coverage afterward, run every shard with the blob reporter, upload the blob files, then merge them in a follow-up job.
Each shard writes .rstest-reports/blob-{index}-{count}.json. The merge job collects those files into one .rstest-reports/ directory, then rstest merge-reports runs the configured reporters on the unified result and merges coverage data. See shard and rstest merge-reports for details.
Publish machine-readable reports
CI tools often need structured report files in addition to terminal output. Add reporters when you need XML, JSON, Markdown, or blob output:
Then upload the report directory:
Use junit for CI test-result integrations, json for custom tooling, md for Markdown summaries, github-actions for GitHub annotations, and blob for sharded report merging. See reporters for the complete list and options.
Cache dependencies
Start with the package-manager cache because it is safe and usually gives the biggest CI improvement. In GitHub Actions, actions/setup-node with cache: pnpm restores the pnpm store based on the lockfile.
Recommended checklist
- Use Node.js
^20.19.0or>=22.12.0to match Rstest's supported runtime range. - Run
rstestin CI, either directly or through a package script. - Install coverage and browser packages only when the workflow needs those features.
- Upload coverage, JUnit, JSON, or blob artifacts with
if: always()if they help debug failures. - Add sharding only after the single-machine workflow is stable.
- Keep Browser Mode browser installation aligned with the browser selected in Rstest config.