Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7f53b56

Browse files
authored
fix(render): Don't reject wrapper types based on statics (#973)
1 parent cde904c commit 7f53b56

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

‎types/index.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export interface RenderOptions<
7070
*
7171
* @see https://testing-library.com/docs/react-testing-library/api/#wrapper
7272
*/
73-
wrapper?: React.ComponentType<{children: React.ReactElement}>
73+
wrapper?: React.JSXElementConstructor<{children: React.ReactElement}>
7474
}
7575

7676
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

‎types/test.tsx‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,32 @@ export function wrappedRenderB(
115115
ui: React.ReactElement,
116116
options?: pure.RenderOptions,
117117
) {
118-
const Wrapper: React.FunctionComponent = ({children}) => {
118+
const Wrapper: React.FunctionComponent<{children?: React.ReactNode}> = ({
119+
children,
120+
}) => {
119121
return <div>{children}</div>
120122
}
121123

122124
return pure.render(ui, {wrapper: Wrapper, ...options})
123125
}
124126

127+
export function wrappedRenderC(
128+
ui: React.ReactElement,
129+
options?: pure.RenderOptions,
130+
) {
131+
interface AppWrapperProps {
132+
userProviderProps?: {user: string}
133+
}
134+
const AppWrapperProps: React.FunctionComponent<AppWrapperProps> = ({
135+
children,
136+
userProviderProps = {user: 'TypeScript'},
137+
}) => {
138+
return <div data-testid={userProviderProps.user}>{children}</div>
139+
}
140+
141+
return pure.render(ui, {wrapper: AppWrapperProps, ...options})
142+
}
143+
125144
/*
126145
eslint
127146
testing-library/prefer-explicit-assert: "off",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /