Skip to content
Discussion options

You must be logged in to vote

We render the full app instead of a component most of the time because it is closer to how it's used, and will ultimately have less false negatives where tests pass but it's actually broken when used in a browser.

 export function renderWithClient(client: QueryClient, ui: React.ReactElement) { 
   client = client || new QueryClient()
   const { rerender, ...result } = render( 
     <QueryClientProvider client={client}>{ui}</QueryClientProvider> 
   ) 
   return { ...   } 
 } 

I've settled on this pattern, thanks everyone!

@julionav ty. I considered this situation, but since the client will still sorta be shared between tests, ultimately decided against it although it should work fine.

also

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@julionav
Comment options

Comment options

You must be logged in to vote
1 reply
@TkDodo
Comment options

Answer selected by yinghaochan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants