From 67cccac23d669f5eb279fbcc7088600efebf2111 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Fri, 1 Nov 2024 13:19:05 +0100 Subject: [PATCH 1/2] 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 --- documentation/docs/07-misc/02-testing.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/documentation/docs/07-misc/02-testing.md b/documentation/docs/07-misc/02-testing.md index f0ed52a3c9b4..f2b1c5c925c9 100644 --- a/documentation/docs/07-misc/02-testing.md +++ b/documentation/docs/07-misc/02-testing.md @@ -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 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) + You can now write unit tests for code inside your `.js/.ts` files: ```js From 832e5617994f37da0b71773013344ad2d51d42c6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 1 Nov 2024 12:08:58 -0400 Subject: [PATCH 2/2] Update documentation/docs/07-misc/02-testing.md --- documentation/docs/07-misc/02-testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/07-misc/02-testing.md b/documentation/docs/07-misc/02-testing.md index f2b1c5c925c9..7609242471ca 100644 --- a/documentation/docs/07-misc/02-testing.md +++ b/documentation/docs/07-misc/02-testing.md @@ -31,7 +31,7 @@ export default defineConfig({ : undefined ``` -> [!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) +> [!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: