Repository navigation
fix(vitest): keep the browser condition out of Node in DOM tests - #437
Merged
Merged
Conversation
- Vitest passes the ssr environment's conditions to Node as `--conditions` for external packages. - In the client test posture the plugin added `browser` to every environment, so Node resolved `browser` exports too. - `msw/node` failed because `@mswjs/interceptors/ClientRequest` exports `null` for `browser`. - jsdom and happy-dom tests run in the client environment, and the Solid runtime is now inlined, so the ssr environment no longer gets `browser` in those runs. - The server posture, browser mode, and a user `external` entry for solid-js keep the old conditions. This builds on the runtime inlining from #433. Fixes #125 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: a6cae59 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
ryansolid
changed the base branch from
fix/369-client-test-inline-runtime
to
next
October 21, 2026 15:58
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.
Fixes #125 on
next. The fix formain(1.x) is in a separate PR.This PR is based on #433 (the #369 fix) and needs it. Merge #433 first. GitHub then retargets this PR to
next.In jsdom and happy-dom tests, Node-only packages such as
msw/nodenow load. Before,setupServerfrommsw/nodefailed withPackage subpath './ClientRequest' is not defined by "exports".Cause
browsercondition to every Vite environment, includingssr.ssrenvironment's conditions to Node as--conditionsfor the packages it leaves external.browserexports for those packages.@mswjs/interceptorsexportsnullforbrowseron./ClientRequest.Changes
ssrenvironment no longer gets thebrowsercondition. Theclientenvironment keeps it.browsermakes@solidjs/testing-libraryload the server build.nodeandedge-runtimeenvironments,ssr: true, and a userexternalentry forsolid-jsare unchanged.Testing
msw3.0.3 and a jsdom test that callssetupServer. It fails without the fix on Vitest 5.0.5 and 4.1.12.vitest/ssr-conditionscheck toexamples/start-ssr/test/run.mjs. It fails without the fix.node test/run.mjs vitestpasses 8/8 andpnpm test:unitpasses.browserto the client environment itself, which DOM tests need. The changeset says "Vitest 4 and later".🤖 Generated with Claude Code