JesusTheHun / storybook-addon-remix-react-router

Use your app router in your stories. A decorator made for Remix React Router and Storybook
Apache License 2.0
45 stars 11 forks source link

Testing navigation state pending #50

Closed Ribosom closed 10 months ago

Ribosom commented 10 months ago

Is there a way to test, if the state of the router is loading/pending?

I have a component with a NavLink, and I want to test the pending-state in Storybook. I found no parameter in reactRouterParameters corresponding to the state of the navigation.

PS: Thanks for your plugin, it is really helpful.

JesusTheHun commented 10 months ago

You can use a loader function that returns a promise that never resolves. If you want to test a general case, that's a valid way to go.

If you want to test a specific case, I would recommend using msw and its infinite mode, so the http requests you make are loading forever.