Files
gmtool/tests/setup.js
T
tevans 1348048d50 feat: <gm-shell> wiring, styles, and AFTERIMAGE boot
Adds the gm-shell root element that owns store/clock/stamps/scenario,
mounts director-rail and dice-tray, handles reached (stamp + persist)
and open-tool (toggle dice tray), and boots the AFTERIMAGE scenario in
main.js. Also adds tests/setup.js + a vite.config.js setupFiles entry:
Node's newer built-in global `localStorage` shadows jsdom's per-window
implementation in vitest's jsdom environment, leaving localStorage
undefined in tests until replaced with a real jsdom-backed instance.
2026-07-20 14:15:50 +01:00

15 lines
636 B
JavaScript

// Workaround: Node's own experimental global `localStorage` (added in recent
// Node versions) shadows jsdom's per-window localStorage before vitest's
// jsdom environment can install it, leaving `localStorage`/`window.localStorage`
// undefined in tests. Replace it with a real jsdom-backed Storage instance.
import { JSDOM } from 'jsdom';
if (typeof localStorage === 'undefined' || typeof localStorage.setItem !== 'function') {
const { window } = new JSDOM('', { url: 'http://localhost/' });
Object.defineProperty(globalThis, 'localStorage', {
value: window.localStorage,
configurable: true,
writable: true,
});
}