-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.js
29 lines (21 loc) · 912 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
24
25
26
27
28
29
// Optional: configure or set up a testing framework before each test.
// If you delete this file, remove `setupFilesAfterEnv` from `jest.config.js`
// Used for __tests__/testing-library.js
// Learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom/extend-expect";
import { TextDecoder, TextEncoder } from "util";
import { resetDB } from "./__tests__/__mocks__/db/utils/reset-db";
// src/setupTests.js
import { server } from "./__tests__/__mocks__/msw/server";
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
// Establish API mocking before all tests.
beforeAll(() => server.listen());
beforeEach(async () => {
await resetDB();
});
// Reset any request handlers that we may add during the tests,
// so they don't affect other tests.
afterEach(() => server.resetHandlers());
// Clean up after the tests are finished.
afterAll(() => server.close());