diff --git a/apps/antalmanac/tests/setup/setup.ts b/apps/antalmanac/tests/setup/setup.ts new file mode 100644 index 000000000..69b8ee9c2 --- /dev/null +++ b/apps/antalmanac/tests/setup/setup.ts @@ -0,0 +1,15 @@ +import { vi } from 'vitest'; + +Object.defineProperty(window, 'matchMedia', { + writable: true, + value: vi.fn().mockImplementation((query) => ({ + matches: false, + media: query, + onchange: null, + addListener: vi.fn(), // deprecated + removeListener: vi.fn(), // deprecated + addEventListener: vi.fn(), + removeEventListener: vi.fn(), + dispatchEvent: vi.fn(), + })), +}); diff --git a/apps/antalmanac/vite.config.ts b/apps/antalmanac/vite.config.ts index 3f0fff255..4ff616641 100644 --- a/apps/antalmanac/vite.config.ts +++ b/apps/antalmanac/vite.config.ts @@ -23,4 +23,8 @@ export default defineConfig({ server: { host: 'localhost', }, + test: { + environment: 'jsdom', + setupFiles: [resolve(__dirname, 'tests/setup/setup.ts')], + }, });