-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
test(react-query): use fake timers for QueryClientProvider.test.tsx #9074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(react-query): use fake timers for QueryClientProvider.test.tsx #9074
Conversation
View your CI Pipeline Execution ↗ for commit 7a6ffe7.
☁️ Nx Cloud last updated this comment at |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9074 +/- ##
===========================================
+ Coverage 44.58% 84.22% +39.64%
===========================================
Files 203 26 -177
Lines 8104 374 -7730
Branches 1809 110 -1699
===========================================
- Hits 3613 315 -3298
+ Misses 4059 50 -4009
+ Partials 432 9 -423
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the QueryClientProvider tests to use fake timers for improved reliability when testing asynchronous query behavior.
- Introduces beforeEach/afterEach hooks to switch between fake and real timers.
- Replaces testing-library’s waitFor with vi.waitFor to accommodate fake timers.
- Updates queryFn implementations from async/await to promise chains.
Comments suppressed due to low confidence (2)
packages/react-query/src/tests/QueryClientProvider.test.tsx:40
- Verify that replacing testing-library's waitFor with vi.waitFor handles asynchronous UI updates as expected under fake timers.
await vi.waitFor(() => rendered.getByText('test'))
packages/react-query/src/tests/QueryClientProvider.test.tsx:12
- Confirm that resetting to real timers after using fake timers does not inadvertently affect subsequent asynchronous tests.
vi.useRealTimers()
No description provided.