Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions apps/loopover-miner-ui/vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ class ResizeObserverStub {
}
globalThis.ResizeObserver ??= ResizeObserverStub as unknown as typeof ResizeObserver;

// Node 26 predefines its own experimental `globalThis.localStorage` accessor (nodejs/node#60303) that
// returns undefined unless the process was started with --localstorage-file. Because that property already
// *exists* on globalThis before jsdom's env is installed, Vitest's populateGlobal skips copying jsdom's
// working Storage over it, so any bare `localStorage.*` call (theme-toggle.test.tsx, mirroring
// theme-toggle.tsx:39) throws "Cannot read properties of undefined". jsdom's real Storage still lives on the
// raw JSDOM window (globalThis.jsdom.window, which is a distinct object from the `window`/globalThis alias);
// point the global at it unconditionally -- a no-op on Node 22/24 where globalThis.localStorage already *is*
// this object, and the actual fix on Node 26+. A `??=` guard would not help (the broken accessor already
// counts as "present"); the property is configurable so redefining it is safe.
const jsdomLocalStorage = (globalThis as { jsdom?: { window?: { localStorage?: Storage } } }).jsdom?.window
?.localStorage;
if (jsdomLocalStorage) {
Object.defineProperty(globalThis, "localStorage", {
value: jsdomLocalStorage,
configurable: true,
writable: true,
});
}

// #7075: ChatConversation wires handlePortfolioQueueChatCommand, which imports chat-action-registry →
// governor-chokepoint → governor-ledger → node:sqlite. jsdom/Vite cannot bundle that builtin (same twin
// pattern as chat-governor-actions.test.tsx / chat-portfolio-queue-actions.test.tsx).
Expand Down
Loading