Skip to content

fix(test): use jsdom storage on Node 26 - #78

Merged
cloader merged 1 commit into
devfrom
codex/fix-node-webstorage
Nov 1, 2026
Merged

cloader merged 1 commit into
devfrom
codex/fix-node-webstorage

Conversation

@cloader

@cloader cloader commented Nov 1, 2026

Copy link
Copy Markdown
Owner

What changed?

On Node 26, native Web Storage globals shadow jsdom's stores in Vitest 3. A plain test run fails when client tests call localStorage.clear(), while sessionStorage points to a different store from the actual DOM.

Add a Vitest setup file that binds both globals to the current jsdom window before test modules load, then restores their original descriptors after the suite. Node-environment suites are left untouched. Add regression coverage for shared DOM/global storage and run CI on Node 22 and 26.

How verified?

  • Reproduced the original localStorage.clear() failure on Windows with Node 26.13.0, including PR fix(client): ignore stale import previews after a new file pick #75's regression test.
  • Without the setup, both new storage tests fail on Node 26; with it, both pass.
  • Node 22.23.1 and Node 26.13.0: typecheck, build, and all 47 test files / 605 tests pass.
  • No Web Storage flags or external setup required.

Related issue

Fixes #71.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] npm test fails on Node 26: Node's experimental localStorage shadows jsdom's, 100 tests fail on a clean clone

1 participant