Features
Rstest brings testing into the Rsbuild and Rspack build pipeline. It reuses build configuration where possible, runs tests through a bundle-based execution model, and provides the core testing features needed for local development and CI.
Reuse existing build setup
Rstest can reuse Rsbuild and Rspack configuration, including module resolution, transforms, and plugin behavior. This reduces the need for a separate test-only build setup and keeps tests aligned with the code that ships.
Learn more about Configuring Rstest.
Built on Rspack
Rstest runs tests on top of Rspack's bundling pipeline, so it can benefit from build-time optimizations such as Tree Shaking and lazyBarrel while keeping test behavior closer to real output.
Transpiled with SWC
By default, Rstest uses Rspack's built-in SWC loader to transform JavaScript and TypeScript. You can customize SWC options in the configuration file when a project needs different syntax or transform behavior.
Learn more about Configuring SWC.
Multi-project testing
Rstest can run multiple test projects in one process, with each project keeping its own configuration and environment. This is useful for monorepos, multi-app workspaces, and projects that need separate Node, DOM, or Browser Mode test targets.
Learn more about Test projects.
Test sharding
Rstest can split test files into shards for parallel execution. In CI, you can distribute the same test suite across multiple machines to reduce total runtime, then use the blob reporter and rstest merge-reports to merge test results and coverage data after all shards complete.
Learn more about Test sharding.
In-source tests
Rstest supports a Rust-like module testing style that lets you write test blocks directly inside source files. It works well for small utilities and helpers where keeping fast checks next to the implementation makes development easier.
Learn more about In-source tests.
Watch mode
When you modify a test file or one of its dependencies, Rstest analyzes the module graph and only reruns the affected test files. This keeps local feedback fast as the test suite grows.
DOM testing
Rstest can simulate the DOM and browser APIs with jsdom or happy-dom. It supports common framework testing workflows for React and Vue, and works with Testing Library and CSS Modules.
Learn more about DOM testing.
Browser mode
Rstest provides Browser Mode for tests that need a real browser instead of a simulated environment such as jsdom or happy-dom. This helps validate browser APIs, rendering behavior, and interactions that are difficult to cover in DOM simulators.
Browser Mode is powered by Playwright and can run tests in Chromium, Firefox, and WebKit, making it suitable for cross-browser verification.
Learn more about Browser mode.
Code coverage
Rstest can collect code coverage with istanbul. Enable it by setting coverage.enabled to true in your Rstest configuration file.
Learn more about Code coverage.
More capabilities
- Jest-compatible assertions and snapshots
- Mock and spy utilities
- File-level sandbox isolation
- Lifecycle hooks for setup and teardown
- Built-in reporters and CI output
- Filtering by directory, project, file, or test name
- VS Code extension