MCPcopy
hub / github.com/TanStack/router / createTestRouter

Function createTestRouter

packages/vue-router/tests/ClientOnly.test.tsx:18–44  ·  view source on GitHub ↗
(initialHistory?: RouterHistory)

Source from the content-addressed store, hash-verified

16})
17
18function createTestRouter(initialHistory?: RouterHistory) {
19 const history =
20 initialHistory ?? createMemoryHistory({ initialEntries: ['/'] })
21
22 const rootRoute = createRootRoute({})
23
24 const indexRoute = createRoute({
25 getParentRoute: () => rootRoute,
26 path: '/',
27 component: () => (
28 <div>
29 <p>Index Route</p>
30 <ClientOnly fallback={<div data-testid="loading">Loading...</div>}>
31 <div data-testid="client-only-content">Client Only Content</div>
32 </ClientOnly>
33 </div>
34 ),
35 })
36
37 const routeTree = rootRoute.addChildren([indexRoute])
38 const router = createRouter({ routeTree, history })
39
40 return {
41 router,
42 routes: { indexRoute },
43 }
44}
45
46describe('ClientOnly', () => {
47 beforeEach(() => {

Callers 1

Calls 4

createMemoryHistoryFunction · 0.90
createRootRouteFunction · 0.90
createRouteFunction · 0.90
createRouterFunction · 0.90

Tested by

no test coverage detected