Replies: 3 comments 7 replies
-
Any thing on how we can test components that use the |
Beta Was this translation helpful? Give feedback.
0 replies
-
This used to work for me, but somewhere along the versions it stopped working export function TestRouter(props: React.PropsWithChildren) {
const router = useMemo(
() =>
createRouter({
routeTree: createRootRoute({
component: () => props.children,
}),
}),
[props.children],
);
return <RouterProvider router={router} />;
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Same problem here, I want to test one component, not the whole app, and I don't find how to wrap the component with the Router |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am doing component testing with Cypress and I am testing a component that include this router's
<Link />
component. When running tests I get the following error:That makes a lot of sense to me, because the component is now not accessed through routes and therefore the
<RouterProvider />
is not mounted.How do I test components that use the
<Link />
component? How can I mock the component or how can I mockuseRouterContext()
?Beta Was this translation helpful? Give feedback.
All reactions