diff --git a/packages/react-router/tests/loaders.test.tsx b/packages/react-router/tests/loaders.test.tsx
index 174ae4eeb2..8d92506468 100644
--- a/packages/react-router/tests/loaders.test.tsx
+++ b/packages/react-router/tests/loaders.test.tsx
@@ -1,4 +1,5 @@
import {
+ act,
cleanup,
configure,
fireEvent,
@@ -17,6 +18,7 @@ import {
createRootRoute,
createRoute,
createRouter,
+ useRouter,
} from '../src'
import { sleep } from './utils'
@@ -380,7 +382,7 @@ test('reproducer #4245', async () => {
render()
// We wait for the initial loader to complete
- await router.load()
+ await act(() => router.load())
const fooLink = await screen.findByTestId('link-to-foo')
expect(fooLink).toBeInTheDocument()
@@ -389,27 +391,257 @@ test('reproducer #4245', async () => {
fireEvent.click(fooLink)
// We immediately see the content of the foo route
- const indexLink = await screen.findByTestId('link-to-index')
+ const indexLink = await screen.findByTestId('link-to-index', undefined, {
+ timeout: WAIT_TIME,
+ })
expect(indexLink).toBeInTheDocument()
// We navigate to the index route
fireEvent.click(indexLink)
// We immediately see the content of the index route because the stale data is still available
- const fooLink2 = await screen.findByTestId('link-to-foo')
+ const fooLink2 = await screen.findByTestId('link-to-foo', undefined, {
+ timeout: WAIT_TIME,
+ })
expect(fooLink2).toBeInTheDocument()
// We navigate to the foo route again
fireEvent.click(fooLink2)
// We immediately see the content of the foo route
- const indexLink2 = await screen.findByTestId('link-to-index')
+ const indexLink2 = await screen.findByTestId('link-to-index', undefined, {
+ timeout: WAIT_TIME,
+ })
expect(indexLink2).toBeInTheDocument()
// We navigate to the index route again
fireEvent.click(indexLink2)
// We now should see the content of the index route immediately because the stale data is still available
- const fooLink3 = await screen.findByTestId('link-to-foo')
+ const fooLink3 = await screen.findByTestId('link-to-foo', undefined, {
+ timeout: WAIT_TIME,
+ })
expect(fooLink3).toBeInTheDocument()
})
+
+test('reproducer #4546', async () => {
+ const rootRoute = createRootRoute({
+ component: () => {
+ return (
+ <>
+