-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.setup.tsx
40 lines (34 loc) · 1.16 KB
/
jest.setup.tsx
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
// 전역 import
import '@testing-library/jest-dom';
// 전역 환경설정
import { RecoilRoot } from 'recoil';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ThemeProvider } from 'styled-components';
import { theme } from '@src/styles/theme';
import GlobalStyle from '@src/styles/global';
import { render as tlrRender } from '@testing-library/react';
import type { RenderOptions } from '@testing-library/react';
const Provider = ({ children }: { children: React.ReactNode }) => {
const queryClient = new QueryClient();
return (
<RecoilRoot>
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={theme}>
<GlobalStyle />
{children}
</ThemeProvider>
</QueryClientProvider>
</RecoilRoot>
);
};
const renderWithProviders = (ui: React.ReactNode, options?: RenderOptions) => {
return tlrRender(<Provider>{ui}</Provider>, options);
};
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace globalThis {
// eslint-disable-next-line no-var, vars-on-top
var render: typeof renderWithProviders;
}
}
global.render = renderWithProviders;