Replies: 1 comment 1 reply
-
import { RouterContext } from 'next/dist/next-server/lib/router-context';
<RouterContext.Provider value={{...mockedRouterContext}}> Obviously not the best answer because the RouterContext is technically not a public API. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As a precursor, the storybook example is pretty useless (when/if I get time, I'll send a PR to tidy it up, the next.js really isn't next-ish and it doesn't answer any basic questions - like this).
I've got a component that calls
useRouter
(a navigate bar) and I want to test it in storybook, but it throws whenrouter.pathname
is access since, I'd imagine,router
is null.What pattern do I need to test this outside of the full nextjs setup?
Beta Was this translation helpful? Give feedback.
All reactions