From fb9fc25a85c8a2dd6069e506418c1a2eebc7131c Mon Sep 17 00:00:00 2001 From: Sheraff Date: Tue, 19 Aug 2025 09:08:15 +0200 Subject: [PATCH] test(router-core): fix flakiness of store-updates 'preload then navigate' test --- .../tests/store-updates-during-navigation.test.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react-router/tests/store-updates-during-navigation.test.tsx b/packages/react-router/tests/store-updates-during-navigation.test.tsx index 2b35683ef5..9a58739274 100644 --- a/packages/react-router/tests/store-updates-during-navigation.test.tsx +++ b/packages/react-router/tests/store-updates-during-navigation.test.tsx @@ -189,7 +189,7 @@ describe("Store doesn't update *too many* times during navigation", () => { test('hover preload, then navigate, w/ async loaders', async () => { const { select } = setup({ beforeLoad: () => Promise.resolve({ foo: 'bar' }), - loader: () => Promise.resolve({ hello: 'world' }), + loader: () => resolveAfter(100, { hello: 'world' }), }) const link = await waitFor(() => @@ -197,6 +197,7 @@ describe("Store doesn't update *too many* times during navigation", () => { ) const before = select.mock.calls.length fireEvent.focus(link) + await new Promise((resolve) => setTimeout(resolve, 50)) fireEvent.click(link) const title = await waitFor(() => screen.getByRole('heading', { name: /Title$/ }), @@ -208,6 +209,6 @@ describe("Store doesn't update *too many* times during navigation", () => { // This number should be as small as possible to minimize the amount of work // that needs to be done during a navigation. // Any change that increases this number should be investigated. - expect(updates).toBe(15) + expect(updates).toBe(14) }) })