blakeblackshear.frigate/web/config/setupTests.js
2021-02-20 08:20:17 -06:00

25 lines
593 B
JavaScript

import 'regenerator-runtime/runtime';
import '@testing-library/jest-dom/extend-expect';
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query) => ({
matches: false,
media: query,
onchange: null,
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
}),
});
window.fetch = () => Promise.resolve();
beforeEach(() => {
jest.spyOn(window, 'fetch').mockImplementation(async (url, opts = {}) => {
throw new Error(`Unexpected fetch to ${url}, ${JSON.stringify(opts)}`);
});
});
jest.mock('../src/env');