mirror of
https://github.com/amir20/dozzle.git
synced 2026-06-23 04:10:12 +00:00
chore: fixes javascript tests
This commit is contained in:
@@ -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;
|
||||
@@ -89,5 +89,6 @@ export default defineConfig(() => ({
|
||||
],
|
||||
test: {
|
||||
include: ["assets/**/*.spec.ts"],
|
||||
setupFiles: ["./assets/test-setup.ts"],
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user