Skip to content

test: keep jsdom's localStorage under Node 26 - #144

Merged
fernandomg merged 4 commits into
mainfrom
fix/132-node26-localstorage
Sep 3, 2026
Merged

test: keep jsdom's localStorage under Node 26#144
fernandomg merged 4 commits into
mainfrom
fix/132-node26-localstorage

Conversation

@fernandomg

Copy link
Copy Markdown
Member

Summary

Closes #132

On Node 26 every vitest suite in the repo fails before its first assertion. Node now ships localStorage as a global, and vitest 4 keeps a global it already finds instead of copying jsdom's, so the tests get undefined. engines.node has no upper bound, so Node 26 is supported on paper, and CI never ran it.

Changes

  • Vitest workers start with --no-experimental-webstorage, so jsdom's localStorage lands on Node 26 as it does on 24
  • CI runs the test suites on Node 26 beside the pinned 24

Deviations

  • The issue names canton-connect; the same cause also fails canton-dappbooster and dapp/frontend, so all three configs change
  • A Node flag per vitest config instead of the issue's in-memory polyfill: nothing hand-written, and it goes when vitest 5 lands, where this is fixed upstream
  • The Node 26 CI job is extra scope; requiring it is a ruleset edit after merge

Acceptance criteria

  • Suite passes on any Node satisfying engines.node

Test plan

Automated tests

  1. On main under Node 26 (nvm use 26), run pnpm test; expect failures in every suite with Cannot read properties of undefined
  2. Check out this branch and run pnpm test; expect every suite green
  3. Run nvm use (Node 24 from .nvmrc) and pnpm test again; expect the same

Manual verification

  1. Open the Checks tab of this PR
  2. Expect 3 - test (node 26) green beside 3 - test

Breaking changes

None.

Checklist

  • Self-reviewed my own diff
  • Tests added or updated
  • Docs updated (if applicable)
  • No unrelated changes bundled in

Screenshots

None.

- Node 26 ships localStorage as a lazy global; vitest 4 keeps a global it finds over jsdom's
- Node 26 failed 40/186 connect, 274/274 dappbooster and 18/155 frontend tests; Node 24 passes
- --no-experimental-webstorage in the workers drops Node's global, so jsdom's lands as on Node 24
- Fixed in vitest 5 (vitest-dev/vitest#10293), refused for v4 (#10873); drop the line on that bump
- engines.node has no upper bound, but every job pins .nvmrc, so Node 26 was never exercised
- A separate job keeps the `3 - test` name the ruleset requires; add this one there after merge
Copilot AI balanced review requested due to automatic review settings September 3, 2026 16:33
@fernandomg fernandomg self-assigned this Sep 3, 2026
@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
demo.canton-dappbooster Ready Ready Preview Sep 3, 2026 5:00pm UTC
docs.canton-dappbooster Ready Ready Preview Sep 3, 2026 5:00pm UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It modifies the CI/CD workflow, which the repository guardrails state must not be changed without team review, and it carries a documented manual follow-up (making the new job a required check via a ruleset edit).

Pull request overview

This PR fixes a test-environment regression that surfaces on Node 26. Node 25+ ships localStorage as a global by default, and under vitest 4 the test runner keeps a global it already finds rather than copying jsdom's, so every suite gets Node's storage (which returns undefined without --localstorage-file) and fails before its first assertion. The fix passes --no-experimental-webstorage to the vitest worker processes so jsdom's localStorage is used, restoring the Node 24 behavior. It also adds a CI job that runs the suites on Node 26 alongside the pinned Node 24, since engines.node has no upper bound and Node 26 was never exercised.

I verified the approach is sound: test.execArgv is a valid top-level option in vitest 4 (poolOptions were flattened to top-level in v4), and --experimental-webstorage has existed since Node 22.4.0, so --no-experimental-webstorage is accepted (and a harmless no-op) on the pinned Node 24.15+ while disabling the shadowing global on Node 25/26. The new CI job mirrors the existing test job exactly, differing only in the Node version.

Changes:

  • Add execArgv: ['--no-experimental-webstorage'] to the three jsdom vitest configs (canton-connect, canton-dappbooster, dapp/frontend) with an explanatory comment.
  • Add a test-node-26 CI job to .github/workflows/pr.yml running pnpm test on Node 26.
File summaries
File Description
canton-connect/vitest.config.ts Passes --no-experimental-webstorage to workers so jsdom's localStorage is used under Node 26.
canton-dappbooster/vitest.config.ts Same flag; this suite's afterEach calls localStorage.clear(), which depends on jsdom's storage.
dapp/frontend/vite.config.ts Same flag added to the nested vitest test block (its LedgerBackend tests touch localStorage).
.github/workflows/pr.yml Adds a test-node-26 job that runs the suites on Node 26 beside the pinned Node 24 job.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pablofullana pablofullana left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@fernandomg
fernandomg merged commit c643f48 into main Sep 3, 2026
9 checks passed
@fernandomg
fernandomg deleted the fix/132-node26-localstorage branch September 3, 2026 17:32
@github-project-automation github-project-automation Bot moved this from In review to Done in Canton - dAppBooster (#390) Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

canton-connect test suite fails on Node 26: Node's localStorage shadows jsdom's

4 participants