ファイル
btrc-hub/frontend/src/test/setup.ts
T
2026-10-31 13:50:10 +09:00

34 行
889 B
TypeScript

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 })) })