Browser mode (experimental)
Rstest provides Browser Mode, allowing you to run tests in a real browser instead of simulated environments like jsdom or happy-dom.
What is browser Mode?
Browser Mode uses Playwright to execute your test code in real browsers (Chromium, Firefox, or WebKit). This means your tests run with the exact same browser APIs and behaviors as in production.
Like Node mode, Browser Mode fails a test file when an unhandled error or promise rejection escapes it — even if every test in the file passed. If a rejection is expected, await the promise or attach a handler inside the test so it does not leak to the page.
Locator API
Browser Mode now supports a Playwright-style Locator workflow: you can use page.getBy* for element queries, then use expect.element(locator) for auto-waiting assertions.
This approach is ideal when you want semantic queries (role/label/text) and chainable assertions, making component tests and DOM tests closer to real user interaction semantics.
See User interactions for detailed usage.
When to use browser mode
Use this decision tree to determine if you need Browser Mode:
Even if your tests work fine in jsdom, we still recommend using Browser Mode. See the comparison table below for specific advantages.
Browser mode vs jsdom/happy-dom
Browser Mode and jsdom/happy-dom represent different trade-offs: Browser Mode provides full browser compatibility and visual debugging but consumes more resources; jsdom/happy-dom runs faster and lighter but can only simulate a subset of browser APIs.
Config compatibility
Most config options behave the same in Browser Mode. The table below collects the exceptions in one place — node-only options that are ignored (with a one-time warning when set to a non-default value), features not supported yet, and options whose scheduling semantics differ:
Next steps
- Getting started - Configure and run your first browser test
- User interactions - Use
page+expect.elementfor semantic tests - Framework guides - Complete configuration and component testing examples for each framework
- User interactions - Simulate user clicks, typing, and other actions