Skip to content

Commit d4f4411

Browse files
authored
test: add delay for flaky focus test (#1762)
1 parent 91e00cf commit d4f4411

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export interface SWRHook {
119119
): SWRResponse<Data, Error>
120120
}
121121

122-
// Middlewares guarantee that a SWRHook receives a key, fetcher, and config as the argument
122+
// Middleware guarantee that a SWRHook receives a key, fetcher, and config as the argument
123123
export type Middleware = (
124124
useSWRNext: SWRHook
125125
) => <Data = any, Error = any>(

src/utils/with-middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const withMiddleware = (
1515
| [Key, Fetcher<Data> | null, SWRConfiguration | undefined]
1616
) => {
1717
const [key, fn, config] = normalize(args)
18-
const middlewares = (config.use || []).concat(middleware)
19-
return useSWR<Data, Error>(key, fn, { ...config, use: middlewares })
18+
const uses = (config.use || []).concat(middleware)
19+
return useSWR<Data, Error>(key, fn, { ...config, use: uses })
2020
}
2121
}

test/use-swr-focus.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ describe('useSWR - focus', () => {
198198
// trigger revalidation
199199
await focusWindow()
200200
await waitForNextTick()
201+
await act(() => sleep(100))
201202
await screen.findByText('data: 5')
202203
})
203204

0 commit comments

Comments
 (0)