Skip to content

Commit 67cccac

Browse files
committed
docs: note browser condition earlier
The browser condition is also necessary to test runes, so it makes sense to add it to the first occurence to the vite config. Also add a note about more fine-grained alias conditions. Closes #13961
1 parent 6a2c28c commit 67cccac

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ Then adjust your `vite.config.js`:
2121
/// file: vite.config.js
2222
import { defineConfig } from +++'vitest/config'+++;
2323

24-
export default defineConfig({ /* ... */ })
24+
export default defineConfig({
25+
// ...
26+
// Tell Vitest to use the `browser` entry points in `package.json` files, even though it's running in Node
27+
resolve: process.env.VITEST
28+
? {
29+
conditions: ['browser']
30+
}
31+
: undefined
2532
```
2633
34+
> [!NOTE] If loading the browser version of all your packages is undesireable, because you for example also test backend libraries, [you may need to resort to an alias configuration](https://github.com/testing-library/svelte-testing-library/issues/222#issuecomment-1909993331)
35+
2736
You can now write unit tests for code inside your `.js/.ts` files:
2837
2938
```js

0 commit comments

Comments
 (0)