I have a component which contains a Link component from react router dom v6.
MyComponent.jsx
...
<Link to='/path'>
Som Text
</Link>
...
But if I try to render this component using react testing library.
render(
<BrowserRouter>
<MyComponent />
</BrowserRouter>,
);
I get this error - TypeError: Cannot read properties of undefined (reading 'createHref').
I have tried removing Link from the component and just replacing it with div. The error goes away so it means it is coming from the Link component.