Skip to content

Commit

Permalink
Clarify how to run unit tests in a browser-like environment
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSidhion authored Nov 10, 2024
1 parent 4bcd01b commit ea9e08a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions documentation/docs/07-misc/02-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
? {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit ea9e08a

Please sign in to comment.