Skip to content

Commit ea9e08a

Browse files
Clarify how to run unit tests in a browser-like environment
1 parent 4bcd01b commit ea9e08a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

documentation/docs/07-misc/02-testing.md

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ import { defineConfig } from +++'vitest/config'+++;
2323

2424
export default defineConfig({
2525
// ...
26+
// Tell Vitest to run in a browser-like environment to allow some runes to function as if they were running in the browser
27+
test: {
28+
environment: 'jsdom'
29+
},
2630
// Tell Vitest to use the `browser` entry points in `package.json` files, even though it's running in Node
2731
resolve: process.env.VITEST
2832
? {
@@ -105,6 +109,8 @@ test('Effect', () => {
105109
});
106110
```
107111

112+
> [!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).
113+
108114
### Component testing
109115

110116
It is possible to test your components in isolation using Vitest.

0 commit comments

Comments
 (0)