Repository navigation
Vitest 5, with a workaround for its browser-mode define bug - #45
Merged
Merged
Conversation
Bumps vitest and @vitest/browser-playwright to 5.0.0 and vitest-browser-svelte to 3.1.0 (dependabot #17). Vitest 5.0.0 injects a browser project's own `define` values at runtime as literal strings (vitest-dev/vitest#11164). SvelteKit's are already stringified, so `__SVELTEKIT_PATHS_BASE__` arrived as '""' and `resolve('/')` as '""#/', failing the Nav component tests. In the browser Vite already provides the defines, and the upstream fix (vitest-dev/vitest#11198, merged after 5.0.0) gives browser projects no runtime defines. A tiny plugin on the client test project does the same in `configResolved`, so no dependency is patched. Without it the three Nav tests fail; with it all 60 unit tests pass. Delete it once Vitest is past 5.0.0 (noted in the svelte-ui skill). Supersedes #17. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GoPfSTf4CwmHMTKzLxLfQR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #17, dependabot's bump of the svelte group: vitest and @vitest/browser-playwright to 5.0.0, vitest-browser-svelte to 3.1.0.
Why #17 couldn't just merge: Vitest 5.0.0 has a bug (vitest-dev/vitest#11164) where a browser test project's
definevalues are injected at runtime a second time, taken literally. SvelteKit's defines are already JSON strings, so its base path arrives as the text""andresolve('/')returns""#/, which failed the three Nav component tests. The fix (vitest-dev/vitest#11198) merged on 2026-09-08, but 5.0.0 is still the latest release.The workaround: the upstream fix gives browser projects no runtime defines, since in the browser Vite already provides them correctly.
vite.config.tsgets a small plugin on the client test project that does the same thing after Vitest resolves the config. No dependency is patched. I traced the exact code path in 5.0.0 before choosing this; an earlier idea, moving SvelteKit's plugin off the root config, didn't help because the browser project takes a different branch.Verified: all 60 unit tests pass with the plugin, and without it exactly the three Nav tests fail. The Nav tests are the regression check. The gotcha is noted in the
svelte-uiskill with the instruction to delete the plugin once Vitest is past 5.0.0.🤖 Generated with Claude Code
https://claude.ai/code/session_01GoPfSTf4CwmHMTKzLxLfQR