Skip to content

Commit

Permalink
docs: note browser condition earlier (#14096)
Browse files Browse the repository at this point in the history
* 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

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

---------

Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
dummdidumm and Rich-Harris authored Nov 1, 2024
1 parent 9883e70 commit aac4cbd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion documentation/docs/07-misc/02-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,18 @@ Then adjust your `vite.config.js`:
/// file: vite.config.js
import { defineConfig } from +++'vitest/config'+++;

export default defineConfig({ /* ... */ })
export default defineConfig({
// ...
// Tell Vitest to use the `browser` entry points in `package.json` files, even though it's running in Node
resolve: process.env.VITEST
? {
conditions: ['browser']
}
: undefined
```
> [!NOTE] If loading the browser version of all your packages is undesirable, because (for example) you 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)
You can now write unit tests for code inside your `.js/.ts` files:
```js
Expand Down

0 comments on commit aac4cbd

Please sign in to comment.