-
Notifications
You must be signed in to change notification settings - Fork 255
/
setupTest.js
38 lines (30 loc) · 921 Bytes
/
setupTest.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 '@testing-library/jest-dom';
import { vi } from 'vitest';
import { setupIntersectionMocking } from 'react-intersection-observer/test-utils';
import i18next from 'i18next';
import createFetchMock from 'vitest-fetch-mock';
import en from './src/locales/en/translation.json';
// vitest doesn't set a default
window.origin = 'http://localhost';
vi.setConfig({ testTimeout: 10_000 });
const fetchMocker = createFetchMock(vi);
// changes default behavior of fetchMock to use the real 'fetch' implementation and not mock responses
beforeEach((context) => {
if (context.task.file.name.includes('/integration')) {
fetchMocker.disableMocks();
} else {
// sets globalThis.fetch and globalThis.fetchMock to our mocked version
fetchMocker.enableMocks();
}
});
/** */
class Path2D {
}
global.Path2D = Path2D;
setupIntersectionMocking(vi.fn);
i18next.init({
lng: 'en',
resources: {
en,
},
});