Closed
Description
@testing-library/react
version: 12.1.1- Testing Framework and version: jest@27.2.4
- typescript@4.4.3
Relevant code or config:
import {MemoryRouter as Router} from 'react-router-dom';
// ...
render(<Whatever />, {wrapper: Router});
What you did:
Use Router
as wrapper
.
What happened:
typescript compile error.
Problem description:
Overload 1 of 2, '(ui: ReactElement<any, string | JSXElementConstructor<any>>, options: RenderOptions<typeof import(".../node_modules/@testing-library/dom/types/queries"), HTMLElement>): RenderResult<...>', gave the following error.
Type 'typeof MemoryRouter' is not assignable to type 'ComponentType<{ children: ReactElement<any, string | JSXElementConstructor<any>>; }> | undefined'.
Type 'typeof MemoryRouter' is not assignable to type 'ComponentClass<{ children: ReactElement<any, string | JSXElementConstructor<any>>; }, any>'.
Types of parameters 'props' and 'props' are incompatible.
Type '{ children: ReactElement<any, string | JSXElementConstructor<any>>; }' is not assignable to type 'MemoryRouterProps | Readonly<MemoryRouterProps>'.
Type '{ children: ReactElement<any, string | JSXElementConstructor<any>>; }' has no properties in common with type 'Readonly<MemoryRouterProps>'.
Overload 2 of 2, '(ui: ReactElement<any, string | JSXElementConstructor<any>>, options?: Omit<RenderOptions<typeof import(".../node_modules/@testing-library/dom/types/queries"), HTMLElement>, "queries"> | undefined): RenderResult<...>', gave the following error.
Type 'typeof MemoryRouter' is not assignable to type 'ComponentType<{ children: ReactElement<any, string | JSXElementConstructor<any>>; }> | undefined'.
Type 'typeof MemoryRouter' is not assignable to type 'ComponentClass<{ children: ReactElement<any, string | JSXElementConstructor<any>>; }, any>'.