Rsbuild doesn't include built-in testing frameworks, but integrates seamlessly with popular testing tools.
This guide will introduce how to add unit testing and end-to-end testing to Rsbuild applications.
Unit tests verify individual components and functions in isolation. Rsbuild can work with testing frameworks like Rstest, Vitest, Jest, and others.
The following example uses Rstest to demonstrate how to add unit testing to a Rsbuild application.
Rstest is a testing framework built on Rsbuild that provides first-class support for Rsbuild applications. It offers Jest-compatible APIs while natively supporting modern features like TypeScript and ESM.
Add test scripts to your package.json
:
Create test files, for example:
These are the basic steps for using Rstest. Check the Rstest documentation for more usage details.
Refer to the following examples for more usage patterns:
End-to-end testing validates complete user workflows, ensuring your application functions correctly in real browser environments.
For E2E testing, we recommend Playwright, a modern end-to-end testing framework. See the Playwright documentation for details.