v7 Framework SPA : is testing impossible ? #13032
-
Hi, I work on a new SPA project and I want to use React Router v7 (framework).
Any Idea ? Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I think the first one is a problem many people reported, the testing helper doesn’t support components using the component props You could create a route component that calls useLoaderData and useActionData and pass that to your own component as a prop The second issue, the createRoutesStub is to test React components in the context of React Router To test loaders and actions you could just call them as normal functions, you will need to pass a Request instance, a params object and a context object Although instead of testing the loaders and actions I recommend you to test the logic inside. If you move that to another functions you don’t need to simulate a request to test them. |
Beta Was this translation helpful? Give feedback.
-
Oops! Support for the props in |
Beta Was this translation helpful? Give feedback.
Oops! Support for the props in
createRoutesStub
was an oversight on our part - adding support for that here: #13528