Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use dynamic routes with the MemoryRouterProvider for rendering in storybook? #78

Open
shawngustaw opened this issue Apr 5, 2023 · 3 comments
Labels
needs more information More information is needed to investigate question OP is asking for clarification or help

Comments

@shawngustaw
Copy link

I know there's a createDynamicrouterParser but it seems like this is only intended to be used in Jest. Is there something equivalent for storybook?

@scottrippey scottrippey added the question OP is asking for clarification or help label Apr 5, 2023
@scottrippey
Copy link
Owner

Yes, it should definitely be doable, but I haven't tried it out yet so there might be some gotchas.

One gotcha that comes to mind: for Storybook you'll need to import a full path that includes the /next-13 route (or /next-12 etc) like this:

import { createDynamicRouteParser } from "next-router-mock/dynamic-routes/next-13";

Otherwise, I think everything else should just work. You'll call mockRouter.useParser(createDynamicRouteParser([...])) just like the documentation says.

Please let me know if you try this out! I'd be happy to update the documentation with a Storybook example.

@scottrippey
Copy link
Owner

All of this should go in your preview.js if you intend for it to be global. Please post back if you've tried it out? I'd be happy to add this to the documentation.

@scottrippey scottrippey added the needs more information More information is needed to investigate label Aug 17, 2023
@MrBr
Copy link

MrBr commented Jan 3, 2024

I can confirm, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more information More information is needed to investigate question OP is asking for clarification or help
Projects
None yet
Development

No branches or pull requests

3 participants