Repository navigation
test(frontend): bind jsdom Storage when Node Web Storage shadows it - #57
Open
mambastick wants to merge 1 commit into
Open
mambastick wants to merge 1 commit into
mambastick wants to merge 1 commit into
Conversation
Node 25+ exposes an experimental global localStorage whose getter returns undefined without --localstorage-file. Vitest keeps that global, shadowing jsdom's Storage and failing 17 tests on Node 26. Rebind localStorage and sessionStorage to the jsdom window in the Vitest setup file. Closes #56 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #56
What and why
On Node 25+ the frontend Vitest suite failed 17 of 178 tests, mostly in
app-shell.test.tsxandapp-navigation.test.tsx, withTypeError: Cannot read properties of undefined (reading 'getItem'). CI pins Node 24, so this only showed up locally.Node 25+ exposes an experimental global Web Storage API. Without
--localstorage-file, itsglobalThis.localStoragegetter returnsundefined. Vitest's jsdom environment keeps that existing global instead of replacing it, so Node's brokenlocalStoragehides jsdom's working one. A probe on Node 26 confirmed this: the globallocalStoragewasundefined, whilejsdom.window.localStorageandsessionStorageworked.frontend/src/test/setup.tsnow rebindslocalStorageandsessionStorageonglobalThisto the jsdom window's realStorageinstances whenever they differ. On Node 24 they are already the same object, so nothing changes there. Production code, test assertions and the Vitest config are unchanged.Checks
vitest runlintbuild--no-experimental-webstorage--localstorage-file=<tmp>tsc -b+vite build)Backend checks were not run because no backend files changed.
Risks / migration / rollback
ExperimentalWarningabout--localstorage-fileonce per worker on Node 25+. It is harmless noise.🤖 Generated with Claude Code