-
Notifications
You must be signed in to change notification settings - Fork 1
/
render.tsx
36 lines (31 loc) · 1.04 KB
/
render.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
import { render, RenderOptions, RenderResult } from "@testing-library/react";
import React from "react";
import { TargemStatefulProvider } from "react-targem";
import "@testing-library/jest-dom";
export const BlankWrapper: React.StatelessComponent<{}> = (props: {
children?: React.ReactNode;
}) => <>{props.children}</>;
const AllTheProviders = (Wrapper: React.ComponentType = BlankWrapper) => ({
children,
}: {
children?: React.ReactNode;
}) => {
return (
<Wrapper>
<TargemStatefulProvider translations={{}}>
{/** StrictMode is useful for `this.setState` functions to be called twice and to prevent side-effects */}
<React.StrictMode>{children}</React.StrictMode>
</TargemStatefulProvider>
</Wrapper>
);
};
const customRender = (
ui: React.ReactElement,
options?: RenderOptions
): RenderResult => {
return render(ui, { ...options, wrapper: AllTheProviders(options?.wrapper) });
};
// re-export everything
export * from "@testing-library/react";
// override render method
export { customRender as render };