Replies: 8 comments 4 replies
-
It would be nice if we are able to test the routing logic without having to rely on ui framework dependencies. I hope there's an example code for this. |
Beta Was this translation helpful? Give feedback.
-
You can just create a router and call methods on it then test the state.
…On Aug 10, 2023 at 2:20 PM -0400, Kevin Do ***@***.***>, wrote:
It would be nice if we are able to test the routing logic without having to rely on libraries like testing library to traverse the dom or have ui framework as part of our tests. I hope that's possible and I wonder what the code would look like.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
The repo has an example of this.
…On Aug 11, 2023 at 3:39 PM -0400, Kacper Arendt ***@***.***>, wrote:
can you provide some example, i don't get it
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
With React it is as simple as: <RouterProvider router={router} defaultComponent={TestingComponent} /> Then in import { createRootRoute, createRouter } from '@tanstack/react-router';
const rootRoute = createRootRoute();
export const router = createRouter({
routeTree: rootRoute
}); |
Beta Was this translation helpful? Give feedback.
-
Documentation on the main site with testing examples would be great. |
Beta Was this translation helpful? Give feedback.
-
Scared this gets forgotten, but some clearer documentation on Tanstack Router + Testing would be greatly appreciated |
Beta Was this translation helpful? Give feedback.
-
I believe tannerlinsley is referring to something like this - router/packages/react-router/tests/loaders.test.tsx Lines 34 to 59 in 0de8af7 Looks quite straightforward to me, will take it for a spin |
Beta Was this translation helpful? Give feedback.
-
Hi Team,
I am trying to test my component and a hook with a vitest and RTL.
How to pass the Tanstack Router as a wrapper? Can you please help me on this.
I have got on idea on testing a Component from the following discussion 604 but still this code helps only for the component testing.
I don't know how to test a custom Hook or redux stores and sagas that has a Tanstack Router wrapper around it.
Is there any way that I can provide the Tanstak Router as a wrapper for the render method?
Beta Was this translation helpful? Give feedback.
All reactions