isolate
- Type:
boolean - Default:
true - CLI:
--isolate,--isolate=false,--no-isolate
Run tests in an isolated environment.
By default, Rstest runs each test in an isolated environment, which avoids the impact of some module side effects and helps improve the stability of the test.
If your code has no side effects, turning off this option will help improve performance because module caches can be reused between different test files.
When isolate is false, a module imported by multiple test files is evaluated once per worker, not once per file. Any code at that shared module's top level — including hooks registered there (e.g. a helper that calls beforeEach at module scope) — therefore runs only for the first file that loads it, not for every file. For setup that must run per file, use setupFiles, which Rstest re-runs for each test file even without isolation.