deadhead-space-freight-tycoon/apps/web/test/setup.ts

20 lines
881 B
TypeScript

import "@testing-library/jest-dom/vitest";
import { cleanup, configure } from "@testing-library/react";
import { afterEach, vi } from "vitest";
import { useConnection } from "../src/state/connection";
afterEach(() => {
cleanup();
// The board remembers what was seen per location (CR-008); start each test fresh.
if (typeof localStorage !== "undefined") localStorage.clear();
// Offline in one test must not leak into the next (Step 11.2).
useConnection.setState({ online: true, lastUpdate: null });
});
// findBy*/waitFor default to 1 s, which a busy parallel run can exceed; wait up to 3 s.
configure({ asyncUtilTimeout: 3000 });
// PixiJS needs WebGL, which jsdom lacks. Component tests use a stand-in canvas;
// the map's logic (projection, camera, scene, hit-testing) is unit-tested directly.
vi.mock("../src/map/MapCanvas", () => import("./map-canvas-double"));