React Query retries failed queries several times with a delay by default, so the error appears after the 1000ms
findBy timeoutTanStack Query (React Query) retries failed queries before it sets the error state. By default it retries 3 times, with growing delays. So the error appears after the 1000ms findBy timeout. In tests, create the QueryClient with retry: false. Raising the findBy timeout would only make the test slow. The tempting option that MSW can't return 500 in Node is wrong. MSW returns 500 responses fine.
Read more
- RTL setup: custom render (https://testing-library.com/docs/react-testing-library/setup)testing-library.com
- About queries (https://testing-library.com/docs/queries/about)testing-library.com