-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.setup.js
23 lines (20 loc) · 887 Bytes
/
jest.setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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/server';
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),
updateWordPressCodeBlocks: jest.fn((str) => str),
};
});
beforeAll(() => mswServer.listen());
afterEach(() => mswServer.resetHandlers());
afterAll(() => mswServer.close());