33 lines
831 B
TypeScript
33 lines
831 B
TypeScript
|
|
import "@testing-library/jest-dom/vitest";
|
||
|
|
import { afterEach, vi } from "vitest";
|
||
|
|
import { cleanup } from "@testing-library/react";
|
||
|
|
|
||
|
|
afterEach(cleanup);
|
||
|
|
|
||
|
|
Object.defineProperty(window, "matchMedia", {
|
||
|
|
writable: true,
|
||
|
|
value: vi.fn().mockImplementation((query: string) => ({
|
||
|
|
matches: false,
|
||
|
|
media: query,
|
||
|
|
onchange: null,
|
||
|
|
addEventListener: vi.fn(),
|
||
|
|
removeEventListener: vi.fn(),
|
||
|
|
addListener: vi.fn(),
|
||
|
|
removeListener: vi.fn(),
|
||
|
|
dispatchEvent: vi.fn(),
|
||
|
|
})),
|
||
|
|
});
|
||
|
|
|
||
|
|
globalThis.requestAnimationFrame = (callback) => window.setTimeout(callback, 0);
|
||
|
|
globalThis.cancelAnimationFrame = (handle) => window.clearTimeout(handle);
|
||
|
|
|
||
|
|
HTMLCanvasElement.prototype.getContext = vi.fn();
|
||
|
|
|
||
|
|
class ResizeObserverMock {
|
||
|
|
observe() {}
|
||
|
|
unobserve() {}
|
||
|
|
disconnect() {}
|
||
|
|
}
|
||
|
|
|
||
|
|
globalThis.ResizeObserver = ResizeObserverMock;
|