Skip to content

Commit 37bcf5d

Browse files
committed
fix act
1 parent debb316 commit 37bcf5d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test/use-swr.test.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -798,16 +798,16 @@ describe('useSWR - revalidate', () => {
798798
await waitForDomChange({ container })
799799
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"0"`)
800800

801-
await act(async () => {
802-
// trigger the slower revalidation
803-
faster = false
804-
fireEvent.click(container.firstElementChild)
805-
await new Promise(res => setTimeout(res, 10))
806-
// trigger the faster revalidation
807-
faster = true
808-
fireEvent.click(container.firstElementChild)
809-
return new Promise(res => setTimeout(res, 210))
810-
})
801+
// trigger the slower revalidation
802+
faster = false
803+
fireEvent.click(container.firstElementChild)
804+
805+
await act(async () => new Promise(res => setTimeout(res, 10)))
806+
// trigger the faster revalidation
807+
faster = true
808+
fireEvent.click(container.firstElementChild)
809+
810+
await act(async () => new Promise(res => setTimeout(res, 210)))
811811
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"1"`)
812812
})
813813

0 commit comments

Comments
 (0)