From a8e1b0105f7595fbfb9ffacea04eefd6d9aeddf0 Mon Sep 17 00:00:00 2001 From: Toru Kobayashi Date: Tue, 9 Mar 2021 00:56:16 +0900 Subject: [PATCH] test: return initialData while revalidating --- test/use-swr-integration.test.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/use-swr-integration.test.tsx b/test/use-swr-integration.test.tsx index 1b23ccce75..5f268fc95f 100644 --- a/test/use-swr-integration.test.tsx +++ b/test/use-swr-integration.test.tsx @@ -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')