39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import '@testing-library/jest-dom/vitest';
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Polyfill: window.matchMedia
|
|
// ---------------------------------------------------------------------------
|
|
// Mantine v8's MantineProvider calls window.matchMedia internally for
|
|
// color scheme detection. jsdom does not implement matchMedia, so we
|
|
// provide a minimal stub to prevent TypeError during test rendering.
|
|
// ---------------------------------------------------------------------------
|
|
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: (query: string) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: () => {},
|
|
removeListener: () => {},
|
|
addEventListener: () => {},
|
|
removeEventListener: () => {},
|
|
dispatchEvent: () => false,
|
|
}),
|
|
});
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Polyfill: ResizeObserver
|
|
// ---------------------------------------------------------------------------
|
|
// Some Mantine components (Popover, Select dropdown) use ResizeObserver
|
|
// which is also not available in jsdom.
|
|
// ---------------------------------------------------------------------------
|
|
|
|
class ResizeObserverStub {
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
}
|
|
|
|
window.ResizeObserver = ResizeObserverStub as unknown as typeof ResizeObserver;
|