State Management · Senior · Question 56 of 75

How should components using TanStack Query be set up in tests?

Explanation

A shared client leaks cache between tests; retries make failing requests take seconds. Mock the network (MSW) rather than the hook.

Further reading

Problem with a question

State Management · Senior · question 56

Test yourself

Take the State Management · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz