Skip to content

Wrapper type breaks types with props other than children #970

Closed
@cfbender

Description

@cfbender
  • @testing-library/react version: 12.1.1
  • Testing Framework and version: jest @ 27.2.2
  • DOM Environment: 5.14.1

Relevant code or config:

type AppWrapperProps = {
  userProviderProps?: UserProviderProps
}

export const AppWrapper: React.FC<AppWrapperProps> = ({
  children,
  userProviderProps = { user: mockUser },
}) => (
  <UserProvider {...userProviderProps}>
...

What you did:

Upgraded @testing-library/react to 12.1.1

What happened:

Type for wrapper broken in #966

Reproduction:

Use wrapper component that has some props that can be passed

Problem description:

The type being inflexible (only allowing children) means that the wrapper can't take props if used anywhere else

Suggested solution:

Something like wrapper?: React.ComponentType<React.PropsWithChildren>

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScriptRelated to TypeScript. Note: only certain maintainers handle TypeScript labeled issues.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions