13 lines
409 B
TypeScript
13 lines
409 B
TypeScript
import type { ReactElement } from 'react';
|
|
import { MemoryRouter } from 'react-router-dom';
|
|
import { render } from '@testing-library/react';
|
|
|
|
type RenderWithRouterOptions = {
|
|
route?: string;
|
|
};
|
|
|
|
export function renderWithRouter(ui: ReactElement, options: RenderWithRouterOptions = {}) {
|
|
const { route = '/' } = options;
|
|
return render(<MemoryRouter initialEntries={[route]}>{ui}</MemoryRouter>);
|
|
}
|