import '@testing-library/jest-dom/vitest' import { cleanup } from '@testing-library/react' import { afterEach, beforeEach, vi } from 'vitest' beforeEach (() => { vi.spyOn (HTMLCanvasElement.prototype, 'getContext').mockReturnValue (null) }) afterEach (() => { cleanup () localStorage.clear () vi.restoreAllMocks () }) Element.prototype.scrollIntoView = function () { ; } window.scroll = function () { ; } // Animation callbacks must advance time and must not recurse synchronously. window.requestAnimationFrame = callback => window.setTimeout ( () => callback (performance.now ()), 16) window.cancelAnimationFrame = identifier => window.clearTimeout (identifier) Object.defineProperty (window, 'matchMedia', { configurable: true, value: vi.fn ().mockImplementation (() => ({ addEventListener: vi.fn (), removeEventListener: vi.fn (), matches: false })) })