test(react-query): use fake timers for QueryClientProvider.test.tsx#9074
Merged
TkDodo merged 1 commit intoTanStack:mainfrom Apr 26, 2025
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.
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()
Hardanish-Singh
approved these changes
Apr 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.