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
|
import { AllProviders } from "@/providers";
import { render, RenderOptions } from "@testing-library/react";
import {
FunctionComponent,
PropsWithChildren,
ReactElement,
StrictMode,
} from "react";
import {
createBrowserRouter,
RouteObject,
RouterProvider,
} from "react-router-dom";
const AllProvidersWithStrictMode: FunctionComponent<PropsWithChildren> = ({
children,
}) => {
const route: RouteObject = {
path: "/",
element: children,
};
// TODO: Update router system
const router = createBrowserRouter([route]);
return (
<StrictMode>
<AllProviders>
<RouterProvider router={router} />
</AllProviders>
</StrictMode>
);
};
const customRender = (
ui: ReactElement,
options?: Omit<RenderOptions, "wrapper">,
) => render(ui, { wrapper: AllProvidersWithStrictMode, ...options });
// re-export everything
export * from "@testing-library/react";
// override render method
export { customRender as render };
export { render as rawRender };
|