import { act , screen } from '@testing-library/react' ; import React from 'react' ; import useSWR , { mutate } from 'swr' ; import { createKey , createResponse , renderWithGlobalCache } from './utils' ; describe ( 'useSWR - context configs' , ( ) => { it ( 'mutate before mount should not block rerender' , async ( ) => { const prefetch = ( ) => createResponse ( 'prefetch-data' ) ; const fetcher = ( ) => createResponse ( 'data' ) ; const key = createKey ( ) ; await act ( ( ) => mutate ( key , prefetch ) ) ; function Page ( ) { const { data } = useSWR ( key , fetcher ) ; return < div > { data } < /div>; } renderWithGlobalCache ( < Page />); screen . getByText ( 'prefetch-data' ) ; await screen . findByText ( 'data' ) ; } ) ; } ) ;