-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.ts
More file actions
46 lines (39 loc) · 1.13 KB
/
setup.ts
File metadata and controls
46 lines (39 loc) · 1.13 KB
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
39
40
41
42
43
44
45
46
import { cleanup } from '@testing-library/react';
import '@testing-library/jest-dom';
import { server } from './src/mocks/server';
import { vi } from 'vitest';
import i18n from './src/i18n';
// msw 서버 시작
beforeAll(() => {
cleanup();
vi.resetAllMocks(); // Mock 초기화
server.listen({ onUnhandledRequest: 'warn' });
});
// 각 테스트 후 핸들러 리셋
afterEach(() => server.resetHandlers());
// msw 서버 종료
afterAll(() => server.close());
i18n.options.react = {
...(i18n.options.react ?? {}),
useSuspense: false,
};
// 로컬스토리에 언어 설정
if (typeof localStorage !== 'undefined') {
localStorage.setItem('i18nextLng', 'ko');
}
i18n.changeLanguage('ko');
// vitest.setup.ts 또는 setupTests.ts
// ResizeObserver를 전역적으로 모킹합니다.
global.ResizeObserver = class ResizeObserver {
observe() {
// do nothing
}
unobserve() {
// do nothing
}
disconnect() {
// do nothing
}
};
// 만약 window 객체에 직접 할당해야 한다면 (예: 일부 라이브러리가 window.ResizeObserver를 직접 참조하는 경우)
// window.ResizeObserver = global.ResizeObserver;