feat(web): i18n with react-i18next (sv/en)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,24 @@ import { afterAll, afterEach } from "vitest";
|
||||
|
||||
import { server } from "./server";
|
||||
|
||||
// Node v26 does not expose localStorage as a global unless --localstorage-file
|
||||
// is passed. Provide a minimal in-memory shim so i18n and other modules that
|
||||
// call localStorage.getItem/setItem work in jsdom tests.
|
||||
if (typeof globalThis.localStorage === "undefined") {
|
||||
const store: Record<string, string> = {};
|
||||
Object.defineProperty(globalThis, "localStorage", {
|
||||
value: {
|
||||
getItem: (key: string) => store[key] ?? null,
|
||||
setItem: (key: string, value: string) => { store[key] = value; },
|
||||
removeItem: (key: string) => { delete store[key]; },
|
||||
clear: () => { Object.keys(store).forEach((k) => { delete store[k]; }); },
|
||||
get length() { return Object.keys(store).length; },
|
||||
key: (i: number) => Object.keys(store)[i] ?? null,
|
||||
},
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
|
||||
// Start MSW at module level so its fetch patch is in place before any test
|
||||
// module captures globalThis.fetch via openapi-fetch's createClient().
|
||||
server.listen({ onUnhandledRequest: "error" });
|
||||
|
||||
Reference in New Issue
Block a user