53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import "@testing-library/jest-dom/vitest";
|
|
import { cleanup, configure } from "@testing-library/react";
|
|
import { MotionGlobalConfig } from "motion/react";
|
|
import { afterAll, afterEach, beforeAll, vi } from "vitest";
|
|
|
|
import { configureAuthClient } from "@/shared/api";
|
|
|
|
import "../shared/i18n";
|
|
import { server } from "./server";
|
|
|
|
// Allow async UI updates on the slower CI runner; local waits stay unchanged.
|
|
if (process.env.CI) configure({ asyncUtilTimeout: 5000 });
|
|
|
|
// Route fades start at opacity 0; under load toBeVisible can catch that frame.
|
|
MotionGlobalConfig.skipAnimations = true;
|
|
|
|
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
|
afterEach(() => {
|
|
cleanup();
|
|
configureAuthClient();
|
|
server.resetHandlers();
|
|
});
|
|
afterAll(() => server.close());
|
|
|
|
class ResizeObserver {
|
|
disconnect() {}
|
|
observe() {}
|
|
unobserve() {}
|
|
}
|
|
|
|
vi.stubGlobal("ResizeObserver", ResizeObserver);
|
|
|
|
// JSDOM has no layout/scrolling; Mantine Combobox scrolls the active option.
|
|
Object.defineProperty(HTMLElement.prototype, "scrollIntoView", {
|
|
configurable: true,
|
|
value: () => {},
|
|
});
|
|
|
|
Object.defineProperty(globalThis, "matchMedia", {
|
|
value: (query: string) => ({
|
|
addEventListener: () => {},
|
|
addListener: () => {},
|
|
dispatchEvent: () => false,
|
|
matches: false,
|
|
media: query,
|
|
onchange:
|
|
null,
|
|
removeEventListener: () => {},
|
|
removeListener: () => {},
|
|
}),
|
|
writable: true,
|
|
});
|