Skip to content

test(setup): a working DOM Storage for renderer tests on Node 25 (#1212) - #1408

Merged
Juliusolsson05 merged 3 commits into
mainfrom
fix/node25-localstorage
Sep 27, 2026
Merged

Juliusolsson05 merged 3 commits into
mainfrom
fix/node25-localstorage

Conversation

@Juliusolsson05

Copy link
Copy Markdown
Owner

Fixes #1212.

Plan: docs/plans/2026-09-27-node25-renderer-storage.md.

Problem

On Node 25, recentCommandHistory.renderer.test.ts failed with window.localStorage.clear is not a function, and a read returned undefined. I reproduced it with Node 25.5.0.

Node 25 turns Web Storage on by default. Without --localstorage-file, its globalThis.localStorage is a half-initialised placeholder (with the warning "--localstorage-file was provided without a valid path"). Because the global already exists, Vitest's happy-dom environment leaves it in place, so renderer code talks to Node's broken storage instead of the DOM's.

What merges

  • testing/setup/storage.ts installWorkingStorage(): puts a happy-dom Storage on localStorage / sessionStorage wherever the existing one has no clear. The renderer setup file calls it. On Node 22/24 it is a no-op.
  • tsconfig.web.json: lists the new setup file.

Tests

  • testing/unit/setupStorage.test.ts: replaces a Node-25-shaped stand-in and leaves a working storage alone. It is a unit test because CI runs Node 24, where the real global is fine.
  • src/renderer/src/app/storageEnvironment.renderer.test.ts: the renderer environment's storage works.
  • Verified on Node 25.5.0 and 24.14.1: the storage-using renderer tests pass on both. On Node 25 without the fix, 1 of 4 files fails.
  • Gates: npx tsc -b + testing/unit + src/renderer/src/app + src/renderer/src/features/command-palette on 25b1a2f4 (45 files, 378 tests).

Out of scope: any other Node 25 incompatibility in the full suite.

🤖 Generated with Claude Code

Juliusolsson05 and others added 2 commits September 27, 2026 04:13
… shadows happy-dom's (#1212)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Juliusolsson05 Juliusolsson05 added the type:chore Maintenance, deps, tests, docs label Sep 27, 2026
…ode 25 file-backed storage (#1408 review c)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Juliusolsson05

Copy link
Copy Markdown
Owner Author

Review disposition (head 47b7fb3)

  • a: MERGE-READY.
  • b: MERGE-READY. The one minor (Node 25 prints its invalid --localstorage-file warning once per test file because the installer reads Node's placeholder getter before replacing it) is accepted: the warning is cosmetic noise, and storage works on both Node 24 and 25. Suppressing it would mean reading the property descriptor instead of the value, which I'll do only if the noise gets in the way.
  • c round 1: FIX-BEFORE-MERGE. The fix (an instanceof Storage check instead of duck typing) went in fail-first at 47b7fb3.
  • c round 2: MERGE-READY. Verified with a seeded Node 25 storage file on Node 25 and 24; the mutations (removing the renderer installer, and the session-storage mutation) fail.

Residual: Node 25 warning noise in test output (b's minor), as above.

@Juliusolsson05
Juliusolsson05 merged commit 81ce5bb into main Sep 27, 2026
2 checks passed
@Juliusolsson05
Juliusolsson05 deleted the fix/node25-localstorage branch September 27, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:chore Maintenance, deps, tests, docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: renderer localStorage setup fails on Node 25

1 participant