-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.setup.js
38 lines (35 loc) · 901 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
30
31
32
33
34
35
36
37
38
import { mockDBClient } from '@server/utils/testUtils';
import { DB_ENV } from '@utils/testUtils/mockData';
jest.doMock('@database', () => ({
getClient: () => mockDBClient().client,
client: mockDBClient().client,
connect: () => {}
}));
jest.doMock('@database/models', () => ({
...mockDBClient().models
}));
jest.doMock('graphql-redis-subscriptions', () => ({
RedisPubSub: () => ({ publish: () => ({}), asyncIterator: () => ({}) })
}));
jest.doMock('ioredis', () =>
jest.fn().mockImplementation(() => ({
publish: () => ({}),
set: msg =>
JSON.stringify({
msg
}),
get: msg =>
JSON.stringify({
msg
})
}))
);
process.env.ENVIRONMENT_NAME = 'test';
beforeEach(() => {
process.env = { ...process.env, ...DB_ENV, ENVIRONMENT_NAME: 'test' };
});
afterEach(() => {
jest.clearAllMocks();
jest.resetAllMocks();
jest.resetModules();
});