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 configurations through adapters, including aliases, transforms, and plugins. This avoids duplicating configuration and keeps test builds aligned with your application or library build.
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 React and Vue testing workflows, 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 jsdom or happy-dom, letting you verify browser APIs, rendering behavior, and interactions that DOM simulators do not cover.
Browser Mode runs on Playwright and supports Chromium, Firefox, and WebKit for cross-browser verification.
Learn more about Browser mode.
Playwright-driven E2E tests
Rstest runs E2E tests against a complete page or app with @rstest/playwright. Tests execute in Node.js workers and use Playwright to drive a local dev server, preview server, or deployed URL while sharing the same runner, configuration, and reporters as other tests.
Learn more about E2E testing.
Test Module Federation applications
Rstest loads real Module Federation remotes in Node, JSDOM, and Browser Mode tests. With @module-federation/rstest, tests exercise remote loading and shared dependencies instead of mocking the federation boundary.
Learn more about Module Federation testing.
Get faster feedback
Watch mode
When a test file or one of its dependencies changes, Rstest analyzes the module graph and reruns only the affected test files, keeping 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 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, keeping quick checks next to small utilities and helpers.
Learn more about In-source tests.
Scale test runs in CI
Multi-project testing
Rstest runs multiple test projects in one process, each with its own configuration and environment. This fits monorepos, multi-app workspaces, and suites that separate Node, DOM, and Browser Mode targets.
Learn more about Test projects.
Test sharding
Rstest splits test files into shards for parallel execution across CI machines, then merges test results and coverage data with the blob reporter and rstest merge-reports once all shards finish.
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.