Skip to content

Commit fb9fc25

Browse files
committed
test(router-core): fix flakiness of store-updates 'preload then navigate' test
1 parent 83ab173 commit fb9fc25

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/react-router/tests/store-updates-during-navigation.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,15 @@ describe("Store doesn't update *too many* times during navigation", () => {
189189
test('hover preload, then navigate, w/ async loaders', async () => {
190190
const { select } = setup({
191191
beforeLoad: () => Promise.resolve({ foo: 'bar' }),
192-
loader: () => Promise.resolve({ hello: 'world' }),
192+
loader: () => resolveAfter(100, { hello: 'world' }),
193193
})
194194

195195
const link = await waitFor(() =>
196196
screen.getByRole('link', { name: 'Posts' }),
197197
)
198198
const before = select.mock.calls.length
199199
fireEvent.focus(link)
200+
await new Promise((resolve) => setTimeout(resolve, 50))
200201
fireEvent.click(link)
201202
const title = await waitFor(() =>
202203
screen.getByRole('heading', { name: /Title$/ }),
@@ -208,6 +209,6 @@ describe("Store doesn't update *too many* times during navigation", () => {
208209
// This number should be as small as possible to minimize the amount of work
209210
// that needs to be done during a navigation.
210211
// Any change that increases this number should be investigated.
211-
expect(updates).toBe(15)
212+
expect(updates).toBe(14)
212213
})
213214
})

0 commit comments

Comments
 (0)