From 1510e805dc2fb83633c1d1bff51b13f16e92a259 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Sun, 3 Oct 2021 11:24:32 +0200 Subject: [PATCH 1/3] Expected behavior for render#wrapper --- types/test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/test.tsx b/types/test.tsx index 7c45eaae..fd90fba5 100644 --- a/types/test.tsx +++ b/types/test.tsx @@ -115,7 +115,9 @@ export function wrappedRenderB( ui: React.ReactElement, options?: pure.RenderOptions, ) { - const Wrapper: React.FunctionComponent = ({children}) => { + const Wrapper: React.FunctionComponent<{children?: React.ReactNode}> = ({ + children, + }) => { return
{children}
} From a7535eb2be7578d4b2ec451371d4a7280f52d333 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Sun, 3 Oct 2021 11:26:19 +0200 Subject: [PATCH 2/3] fix(render): Don't reject wrapper types based on statics --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 3baf7b5e..92eb2d7b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -70,7 +70,7 @@ export interface RenderOptions< * * @see https://testing-library.com/docs/react-testing-library/api/#wrapper */ - wrapper?: React.ComponentType<{children: React.ReactElement}> + wrapper?: React.JSXElementConstructor<{children: React.ReactElement}> } type Omit = Pick> From 54057ef2b5c54346b2fb7a0d54fff617117d99de Mon Sep 17 00:00:00 2001 From: eps1lon Date: Sun, 3 Oct 2021 11:28:05 +0200 Subject: [PATCH 3/3] Verify the fix worked for wider props --- types/test.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/types/test.tsx b/types/test.tsx index fd90fba5..71ea30a9 100644 --- a/types/test.tsx +++ b/types/test.tsx @@ -124,6 +124,23 @@ export function wrappedRenderB( return pure.render(ui, {wrapper: Wrapper, ...options}) } +export function wrappedRenderC( + ui: React.ReactElement, + options?: pure.RenderOptions, +) { + interface AppWrapperProps { + userProviderProps?: {user: string} + } + const AppWrapperProps: React.FunctionComponent = ({ + children, + userProviderProps = {user: 'TypeScript'}, + }) => { + return
{children}
+ } + + return pure.render(ui, {wrapper: AppWrapperProps, ...options}) +} + /* eslint testing-library/prefer-explicit-assert: "off",