import { afterEach, vi } from 'vitest'; class TestDOMMatrix { a = 1; b = 0; c = 0; d = 1; e = 0; f = 0; } if (typeof globalThis.DOMMatrix === 'undefined') { globalThis.DOMMatrix = TestDOMMatrix as unknown as typeof DOMMatrix; } const hasDom = typeof window !== 'undefined'; afterEach(() => { if (!hasDom) return; document.body.innerHTML = ''; document.head.innerHTML = ''; }); global.ResizeObserver = vi.fn().mockImplementation(() => ({ observe: vi.fn(), unobserve: vi.fn(), disconnect: vi.fn(), })); if (hasDom) { Object.defineProperty(window, 'matchMedia', { writable: true, value: vi.fn().mockImplementation((query) => ({ matches: false, media: query, onchange: null, addListener: vi.fn(), removeListener: vi.fn(), addEventListener: vi.fn(), removeEventListener: vi.fn(), dispatchEvent: vi.fn(), })), }); } global.IntersectionObserver = vi.fn().mockImplementation(() => ({ observe: vi.fn(), unobserve: vi.fn(), disconnect: vi.fn(), }));