diff --git a/documentation/docs/07-misc/02-testing.md b/documentation/docs/07-misc/02-testing.md index 1c3d4ba6e1ef..0b3d7245c8f8 100644 --- a/documentation/docs/07-misc/02-testing.md +++ b/documentation/docs/07-misc/02-testing.md @@ -23,6 +23,10 @@ import { defineConfig } from +++'vitest/config'+++; export default defineConfig({ // ... + // Tell Vitest to run in a browser-like environment to allow some runes to function as if they were running in the browser + test: { + environment: 'jsdom' + }, // Tell Vitest to use the `browser` entry points in `package.json` files, even though it's running in Node resolve: process.env.VITEST ? { @@ -105,6 +109,8 @@ test('Effect', () => { }); ``` +> [!NOTE] `$effect.root` is ignored in a backend testing environment. If your `vite.config.js` or `vitest.config.ts` do not specify a browser-like environment, the code in the test defined above will not run, and the test will misleadingly report that it was successful (because there was no code to run). + ### Component testing It is possible to test your components in isolation using Vitest.