> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# 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](https://rspack.rs/guide/advanced/lazy-barrel) 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](/guide/advanced/adapters.md), 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](/guide/basic/configure-rstest.md) and [Configuring SWC](/guide/basic/configure-rstest.md#configure-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](/config/test/test-environment.md#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](https://playwright.dev/) and can run tests in Chromium, Firefox, and WebKit, making it suitable for cross-browser verification.

Learn more about [Browser mode](/guide/browser-testing.md).

### Playwright-driven E2E tests

Rstest can run E2E tests against a complete page or app with [@rstest/playwright](https://github.com/web-infra-dev/rstest/tree/main/packages/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 [E2E testing](/guide/basic/e2e-testing.md).

### Test Module Federation applications

Rstest can load real [Module Federation](https://module-federation.io/) remotes in Node, JSDOM, and Browser Mode tests. With [@module-federation/rstest](https://github.com/module-federation/core), tests exercise remote loading and shared dependencies instead of replacing the federation boundary with mocks.

Learn more about [Module Federation testing](/guide/advanced/module-federation.md).

## 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


[Added in v0.12.0](https://github.com/web-infra-dev/rstest/releases/tag/v0.12.0)

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](/config/test/pool.md) 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](/config/test/include-source.md).

## 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](/guide/basic/projects.md).

### 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](/guide/basic/cli.md#sharding-tests).

### 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](/config/test/coverage.md) for provider selection and configuration.

## More capabilities

- [Jest-compatible assertions](/api/runtime-api/test-api/expect.md) and [snapshot testing](/guide/basic/snapshot.md)
- [Mock and spy utilities](/guide/basic/mock.md)
- [File-level isolation](/config/test/isolate.md)
- [Lifecycle hooks for setup and teardown](/api/runtime-api/test-api/hooks.md)
- [Built-in reporters and CI output](/guide/basic/reporters.md)
- [Filtering by directory, project, file, or test name](/guide/basic/test-filter.md)
- [VS Code extension](/guide/basic/vscode-extension.md)
