2026-06-13 09:52:56 +02:00
|
|
|
/**
|
|
|
|
|
* Vitest global setup file.
|
|
|
|
|
* Imports @testing-library/jest-dom to extend vitest matchers with DOM assertions.
|
2026-06-13 10:04:14 +02:00
|
|
|
*
|
|
|
|
|
* Also polyfills browser APIs that jsdom does not implement but Mantine needs:
|
|
|
|
|
* - window.matchMedia (Mantine uses it for color-scheme detection)
|
|
|
|
|
* - ResizeObserver (Mantine uses it for responsive components)
|
2026-06-13 09:52:56 +02:00
|
|
|
*/
|
|
|
|
|
import '@testing-library/jest-dom'
|
2026-06-13 10:04:14 +02:00
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// window.matchMedia polyfill (jsdom does not implement this)
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
|
|
|
writable: true,
|
|
|
|
|
value: (query: string) => ({
|
|
|
|
|
matches: false,
|
|
|
|
|
media: query,
|
|
|
|
|
onchange: null,
|
|
|
|
|
addListener: () => {},
|
|
|
|
|
removeListener: () => {},
|
|
|
|
|
addEventListener: () => {},
|
|
|
|
|
removeEventListener: () => {},
|
|
|
|
|
dispatchEvent: () => false,
|
|
|
|
|
}),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// ResizeObserver polyfill (jsdom does not implement this)
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
if (typeof ResizeObserver === 'undefined') {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
;(globalThis as any).ResizeObserver = class ResizeObserver {
|
|
|
|
|
observe() {}
|
|
|
|
|
unobserve() {}
|
|
|
|
|
disconnect() {}
|
|
|
|
|
}
|
|
|
|
|
}
|