aboutsummaryrefslogtreecommitdiffstats
path: root/jest.setup.js
blob: 718f2745d7fb314f52db43da797c0408569e89a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { afterAll, afterEach, beforeAll, jest } from '@jest/globals';
import '@testing-library/jest-dom/jest-globals';
import nextRouterMock from 'next-router-mock';
import './tests/jest/__mocks__/matchMedia.mock';
import { mswServer } from './tests/msw';

jest.mock('next/router', () => nextRouterMock);
jest.mock('next/dynamic', () => () => 'dynamic-import');

/* Jest complains about "Must use import to load ES Module" when importing
 * unified and rehype modules. Maybe it is not the right way to avoid those
 * errors but for now it is the only things that work. */
jest.mock('src/utils/helpers/rehype.ts', () => {
  return {
    __esModule: true,
    updateContentTree: jest.fn((str) => str),
  };
});

beforeAll(() => mswServer.listen());
afterEach(() => mswServer.resetHandlers());
afterAll(() => mswServer.close());