Quick start
Online examples
You can try Rstest online without any setup by using the following examples:
Setup environment
Before getting started, install Node.js 20.19.0 or later in the 20.x line, or 22.12.0 or later (^20.19.0 || >=22.12.0). We recommend an LTS version.
Check the current Node.js version with the following command:
If you do not have Node.js installed in your current environment, or the installed version is too low, you can use nvm or fnm to install it:
Using Rstest
Agent prompt
If you are using a coding agent, copy the following prompt to set up Rstest automatically (for migrating from Jest, Vitest, or Playwright Test, or installing Agent Skills, see the AI guide):
Copy this prompt and send it to your coding agent.
Manual installation
Install @rstest/core as a dev dependency:
Add a test script in package.json:
Run tests with npm run test, yarn test, pnpm test, or directly with npx rstest.
Rstest provides watch, run, and list commands; see CLI Tools for all commands and options.
Writing tests
Create a source file and a matching test file (or use in-source tests, similar to Rust tests):
Run the test command configured in Using Rstest. Rstest outputs:
Type checking
Rstest transforms TypeScript so tests can run, but does not check types. A passing test run does not mean the project has no type errors.
Run your project's type check separately. For a project with TypeScript and a tsconfig.json, you can add a script:
Run both test and typecheck in CI to check runtime behavior and types.
Next steps
If you want to see complete project structures, refer to these common examples:
- node: Node.js testing and coverage collection.
- react: React component, hook, and SSR tests with happy-dom.
- vue: Vue component and SSR testing.
- browser-react: React component testing in Browser Mode.
For more examples, see Rstest examples.