blob: 0f6df68ba407d944e632159f5ad7c772ac964723 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/* eslint-disable @typescript-eslint/no-empty-function */
import { vitest } from "vitest";
import "@testing-library/jest-dom";
// 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;
window.scrollTo = () => {};
|