Skip to content

Commit

Permalink
test: return initialData while revalidating
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Mar 8, 2021
1 parent 1fd4569 commit a8e1b01
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/use-swr-integration.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ describe('useSWR', () => {

// a request is still in flight
await act(() => sleep(10))
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"loading"`)
// while validating, SWR returns the initialData
// https://github.com/vercel/swr/pull/961/files#r588928241
expect(container.firstChild.textContent).toMatchInlineSnapshot(
`"hello, Initial"`
)

// render with data the fetcher returns
await screen.findByText('hello, initial-data-with-initial-data-update')
Expand Down

0 comments on commit a8e1b01

Please sign in to comment.