The window.matchMedia API (used for accessibility features) was not mocked in tests, causing unhandled rejections when replay.ts tried to check prefers-reduced-motion. Added the mock to both test-setup.ts and the beforeEach hook in replay.test.ts to ensure it's available before modules load. Closes: bf-5cwi Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
21 lines
559 B
TypeScript
21 lines
559 B
TypeScript
/**
|
|
* Vitest setup file for browser API mocks.
|
|
*/
|
|
import { vi } from 'vitest';
|
|
|
|
// Mock matchMedia for accessibility features in replay.ts
|
|
// Must be set up before tests import modules that use it
|
|
const matchMediaMock = vi.fn().mockImplementation((query: string) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(),
|
|
removeListener: vi.fn(),
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
}));
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: matchMediaMock,
|
|
});
|