2023-02-10 15:10:13 +00:00
|
|
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
|
|
|
2022-03-28 17:10:24 +00:00
|
|
|
import "@testing-library/jest-dom";
|
2023-02-10 15:10:13 +00:00
|
|
|
import { vitest } from "vitest";
|
|
|
|
|
|
|
|
// From https://stackoverflow.com/questions/39830580/jest-test-fails-typeerror-window-matchmedia-is-not-a-function
|
|
|
|
Object.defineProperty(window, "matchMedia", {
|
|
|
|
writable: true,
|
|
|
|
value: vitest.fn().mockImplementation((query) => ({
|
|
|
|
matches: false,
|
|
|
|
media: query,
|
|
|
|
onchange: null,
|
|
|
|
addListener: vitest.fn(), // Deprecated
|
|
|
|
removeListener: vitest.fn(), // Deprecated
|
|
|
|
addEventListener: vitest.fn(),
|
|
|
|
removeEventListener: vitest.fn(),
|
|
|
|
dispatchEvent: vitest.fn(),
|
|
|
|
})),
|
|
|
|
});
|
|
|
|
|
|
|
|
// From https://github.com/mantinedev/mantine/blob/master/configuration/jest/jsdom.mocks.js
|
|
|
|
class ResizeObserver {
|
|
|
|
observe() {}
|
|
|
|
unobserve() {}
|
|
|
|
disconnect() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.ResizeObserver = ResizeObserver;
|