'node' | 'jsdom' | 'happy-dom'
'node'
--testEnvironment=node
The environment that will be used for testing.
The default environment in Rstest is a Node.js
environment. If you are building a web application, you can use a browser-like environment through jsdom
or happy-dom
instead.
Rstest supports jsdom and happy-dom for mocking DOM and browser APIs.
If you want to enable DOM testing, you can use the following configuration:
You also need to install the corresponding package:
For jsdom
For happy-dom
After enabling DOM testing, you can write tests that use browser APIs like document
and window
.