I'm trying to test a component that uses Link
. This said component is loaded by a parent that uses BrowserRouter
.
I'm getting the below error while running the test:
Invariant Violation: You should not use <Link> outside a <Router>
16 | const getPlanDetail = () => Promise.resolve(PlanDetail);
17 |
> 18 | const wrapper = mount(
| ^
19 | <StaticRouter location="/viewDetail/1" context=>
20 | <PlanDetail getPlanDetail={getPlanDetail} />
21 | </StaticRouter>
And I'm at loss on what to do. Previously, just adding the wrapper StaticRouter
worked perfectly, now I'm unsure on what's missing.
My import on the test file is import {StaticRouter} from 'react-router-dom';
Also tried wrapping the component with MemoryRouter
instead of StaticRouter
, same result.
Any ideas? Thanks!
Aucun commentaire:
Enregistrer un commentaire