T
TanStack3y ago
like-gold

React test stuck on `isLoading` condition

Here is a reproducible sandbox: https://codesandbox.io/s/strange-sound-86mc3p?file=/src/Accounts.tsx Run the test and check the console, this is the result:
<body>
<div>
Loading...
</div>
</body>
<body>
<div>
Loading...
</div>
</body>
Running the actual app, you can see that accounts are rendered in the Accounts component. Why is test stuck on the isLoading condition?
rostgoat
CodeSandbox
strange-sound-86mc3p - CodeSandbox
strange-sound-86mc3p by rostgoat using @tanstack/react-query, @testing-library/react, @testing-library/user-event, axios, jest, loader-utils, msw, react, react-dom
2 Replies
adverse-sapphire
adverse-sapphire3y ago
probably because of:
Error: Uncaught [TypeError: window.matchMedia is not a function]
Error: Uncaught [TypeError: window.matchMedia is not a function]
that is also in the logs ?
like-gold
like-goldOP3y ago
yea you're right. moving that into the test fixed it

Did you find this page helpful?