1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2025-01-20 22:08:54 +00:00
bazarr/frontend/test/setup.ts
2023-02-11 01:21:09 +08:00

30 lines
865 B
TypeScript

/* eslint-disable @typescript-eslint/no-empty-function */
import "@testing-library/jest-dom";
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;
window.scrollTo = () => {};