setupTests.js 567 B

12345678910111213141516171819202122
  1. import 'regenerator-runtime/runtime';
  2. import '@testing-library/jest-dom/extend-expect';
  3. Object.defineProperty(window, 'matchMedia', {
  4. writable: true,
  5. value: (query) => ({
  6. matches: false,
  7. media: query,
  8. onchange: null,
  9. addEventListener: jest.fn(),
  10. removeEventListener: jest.fn(),
  11. dispatchEvent: jest.fn(),
  12. }),
  13. });
  14. window.fetch = () => Promise.resolve();
  15. beforeEach(() => {
  16. jest.spyOn(window, 'fetch').mockImplementation(async (url, opts = {}) => {
  17. throw new Error(`Unexpected fetch to ${url}, ${JSON.stringify(opts)}`);
  18. });
  19. });