Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/vitest-5-shared-server-projects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@solidjs/vite-plugin': patch
---

Vitest 5 inline projects get the plugin's test configuration again (#369). Vitest 5 defaults `test.sharedViteServer` to `true`, so an inline project that only changes `test` options reuses the root Vite server and resolves its options from the raw root `test` block, without running the plugin's `config` hook. Such projects lost everything the hook injects: a `test.environment: 'node'` project kept the root's `browser` condition (`isServer` was `false`), and jsdom projects lost the `@testing-library/jest-dom` setup file and the `solid-js` `server.deps` handling. When the root config declares `test.projects` and leaves `test.sharedViteServer` unset, the plugin now sets it to `false` so every project resolves its own Vite config, as it did under Vitest 4. An explicit `sharedViteServer` value is respected.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,8 @@ test: {
},
```

The posture is chosen while each project resolves its own Vite config. Vitest 5 lets inline projects reuse the root Vite server instead (`test.sharedViteServer`, on by default), which skips that step, so the plugin sets `sharedViteServer: false` when the root config declares `test.projects`. Setting the option yourself overrides this; with `true`, every shared project runs with the root config's posture and without the injected `jest-dom` setup file.

# Credits

- [solid-js](https://github.com/solidjs/solid)
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,11 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin[] {
test.environment = 'jsdom';
}

// Vitest 5 inline projects reuse the root server and never run this hook (#369).
if (userTest.projects && userTest.sharedViteServer === undefined) {
test.sharedViteServer = false;
}

if (serverTestPosture) {
// The worker pool is shared across the whole vitest workspace and
// imports externalized deps natively with `--conditions` derived
Expand Down
Loading