Skip to content

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

Closed

Description

@timacek

What happens?

On Node.js 26, a clean clone of dev passes npm run typecheck and npm run build, but
npm test fails 100 of 602 tests across 9 files. The first failure of each affected file is:

TypeError: Cannot read properties of undefined (reading 'clear')
 ❯ tests/sticky-group-head.spec.ts:29:16

npm test reports:

Test Files  9 failed | 36 passed (45)
     Tests  100 failed | 502 passed (602)

CI (Node 22) is green, so the breakage is invisible upstream. Any contributor building from
source on a current Node release hits it and may believe they broke something.

How to reproduce

git clone https://github.com/cloader/dsh-taskboard.git
cd dsh-taskboard
npm ci
node --version        # v26.13.0
npm test              # 100 failed / 602

Workaround (confirms the cause, not a project-code defect):

NODE_OPTIONS=--no-experimental-webstorage npm test   # 45 files / 602 tests pass

Why

  • Node 26 exposes an experimental localStorage global. Without --localstorage-file it is
    undefined and accessing it prints
    ExperimentalWarning: localStorage is not available because --localstorage-file was not provided.
  • Vitest 3.2.7 (the version the lockfile installs) only copies jsdom window properties onto
    globalThis for names that are still free: populateGlobal's getWindowKeys() keeps a key
    only when it is absent from the global object. So on Node 26 the bare localStorage used by
    the tests resolves to Node's undefined getter instead of jsdom's Storage.
  • jsdom's real window is still reachable: Vitest sets dom.window.jsdom = dom, and the jsdom
    key is copied to the global object, so globalThis.jsdom.window.localStorage works.

This is test infrastructure only — the plugin itself is unaffected.

Proposed fix

Add vitest.config.ts with a small setup file (tests/setup-storage.ts) that, when
globalThis.jsdom?.window exists, re-defines localStorage / sessionStorage on globalThis
from the jsdom window. On Node 22 the global is not defined, so the setup is a no-op and CI keeps
passing unchanged.

I have this working locally on Node 26.13 (Windows 11): 45 files / 602 tests pass,
npm run typecheck and npm run build are clean. The patch is two small files
(vitest.config.ts + tests/setup-storage.ts); I can open a PR for it if you want the fix.

Environment

  • dsh-taskboard: 0.9.7 / dev at fb97e7f (also reproduced on 0.9.6 @ 3054eba)
  • DSH: 0.2.1-rc.2
  • OS: Windows 11
  • Node: v26.13.0, npm 11.20.0
  • Vitest: 3.2.7, jsdom 25.0.1

Additional context

An optional follow-up would be to run CI on a second Node line (for example 22 + 26 or 24) so
this class of breakage surfaces on the PR instead of in a contributor's terminal. I'm not
including that in the fix PR to keep it one concern.

Activity

  1. cloader commented on Nov 1, 2026

    @cloader
    Owner

    Thanks for reporting this and documenting the Node 26 workaround. Closing this issue for now.

    For clarity, PR #75 reports that all 603 tests passed on Node 26.13, and its description explicitly notes that the suite additionally needs the jsdom localStorage setup discussed in this issue. That setup is not included in the merged changes: #75 fixes the separate import-preview race tracked in #72.

    This issue is therefore closed as not planned, rather than marked as fixed by #75.

  2. reopened this on Nov 1, 2026
  3. cloader commented on Nov 1, 2026

    @cloader
    Owner

    A fix is now available in #78, targeting dev.

    The failure was reproduced on Node 26.13.0. The fix makes jsdom test suites use their own localStorage and sessionStorage, restoring the original globals after each suite. Both new regression tests fail without the setup and pass with it.

    Typecheck, build, and all 47 test files / 605 tests pass locally on Windows with Node 22.23.1 and Node 26.13.0. GitHub CI also passes on both Node 22 and Node 26, which is now included in the CI matrix. No Web Storage flags or external setup are required.

    This issue is open while the fix awaits merge.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions