TanStackT
TanStack3y ago
17 replies
dangerous-fuchsia

Vitest rendering an empty div when RouterProvider is used

I have found that when unit testing with Vitest, if I pass a RouterProvider to the render function, the result is always a empty div, i.e:
<body>
  <div />
</body>


I've tried to follow a couple of examples of wrappers that have been posted here and on GitHub, but they all have the same result.

I've created a minimal reproduction here:
https://stackblitz.com/edit/tanstack-router-1wnwna?file=src%2Fmain.test.tsx&view=editor

Just run npm run test to see what I mean.

Any advice is greatly appreciated.
StackBlitzDani Bednarski
Run official live example code for Router Basic, created by Tanstack on StackBlitz
Router - Empty div rendered in vitest - StackBlitz
Was this page helpful?