chore: fixes javascript tests

This commit is contained in:
Amir Raminfar
2026-02-16 11:47:14 -08:00
parent 8057bffd33
commit 51a92ba448
2 changed files with 16 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
// Node v25+ ships a built-in localStorage that lacks the Web Storage API
// (getItem/setItem/removeItem). Replace it with a spec-compliant shim so
// libraries like @vue/devtools-kit work correctly in tests.
const store = new Map<string, string>();
globalThis.localStorage = {
getItem: (key: string) => store.get(key) ?? null,
setItem: (key: string, value: string) => store.set(key, String(value)),
removeItem: (key: string) => store.delete(key),
clear: () => store.clear(),
get length() {
return store.size;
},
key: (index: number) => [...store.keys()][index] ?? null,
} as Storage;
+1
View File
@@ -89,5 +89,6 @@ export default defineConfig(() => ({
],
test: {
include: ["assets/**/*.spec.ts"],
setupFiles: ["./assets/test-setup.ts"],
},
}));