Features
Rstest is a JavaScript and TypeScript testing framework built on Rsbuild and Rspack. Its bundle-based execution model uses Rspack's Rust-based build pipeline and SWC transforms for fast test compilation. Reuse your build configuration, test in Node.js or a browser, and run local development and CI workflows with the same runner.
Fast bundle-based execution
Rstest uses Rspack to bundle tests based on their dependency graph, with its built-in SWC loader transforming JavaScript and TypeScript. This brings build-time optimizations directly into the test workflow.
Optimizations such as lazyBarrel skip unused re-exports in side-effect-free barrel files, reducing unnecessary module processing and speeding up tests in large projects with complex dependency graphs.
Reuse existing build setup
Reuse existing Rsbuild, Rslib, or Rspack configuration through adapters, including aliases, transforms, and plugins. This reduces duplicate configuration and helps keep tests aligned with your application or library's build setup.
See Configuring Rstest and Configuring SWC.
Test in Node.js and browsers
Run tests in the default Node.js environment, simulate the DOM for component tests, or use a real browser when browser behavior matters.
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.
Playwright-driven E2E tests
Rstest can run E2E tests against a complete page or app with @rstest/playwright. Tests run in Node.js workers and use Playwright to drive a local dev server, preview server, or deployed URL while sharing the same Rstest runner, configuration, and reporting workflow as other tests.
Learn more about Playwright.
Test Module Federation applications
Rstest can load real Module Federation remotes in Node, JSDOM, and Browser Mode tests. With @module-federation/rstest, tests exercise remote loading and shared dependencies instead of replacing the federation boundary with mocks.
Learn more about Module Federation testing.
Get faster feedback
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.
VM mode
For suites where worker startup and dependency compilation take a large share of the runtime, VM mode offers vmForks and vmThreads pools. They reuse child processes or worker threads while creating a fresh vm.Context, module graph, and test environment for each test file.
VM pools can reduce repeated startup and compilation work. Setup files and module evaluation still run for every file, and process-level state is not isolated by the VM context. Start with the default forks pool and check VM compatibility before switching.
See Choosing a pool for configuration, memory recycling, and compatibility details.
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.
Scale test runs in CI
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.
Code coverage
Collect code coverage with the istanbul or v8 provider, generate reports, and enforce coverage thresholds in CI. Coverage is also available in Browser Mode, with provider support depending on the browser and run mode.
See Code coverage for provider selection and configuration.