test(query-core/hydration): replace 'vi.waitFor' with 'vi.advanceTimersByTimeAsync' and use 'queryKey' helper for infinite query tests#10944
Conversation
…rsByTimeAsync' and use 'queryKey' helper for infinite query tests
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe hydration test suite for infinite queries is refactored: all six test scenarios replace ChangesInfinite query hydration test refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:sherif,test:knip,tes... |
❌ Failed | 1m 22s | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-06-14 12:31:41 UTC
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
size-limit report 📦
|

🎯 Changes
The infinite query tests in
hydration.test.tsxwrappedprefetchInfiniteQuery/fetchInfiniteQuerycalls invi.waitFor(...)while the suite runs under fake timers (vi.useFakeTimers()).vi.waitForpolls a callback that returns a fresh prefetch promise on every tick, which is the wrong tool under fake timers and made these tests slow.This replaces that pattern with the standard fake-timer flow already used throughout the file.
Changes:
vi.waitFor(() => client.prefetch/fetchInfiniteQuery(...))calls withconst promise = client.prefetch/fetchInfiniteQuery(...)+await vi.advanceTimersByTimeAsync(...)+await promise.sleep(10)in the convertedqueryFns and advance by10(single page) /20(thepages: 2test) so the timer control is deterministic.asyncfrom the convertedqueryFn: ({ pageParam }) => sleep(...).then(...)arrows (they only return a promise).queryKey()helper in these tests for uniqueness and consistency with the rest of the file.No assertions were changed. The whole
hydration.test.tsxsuite (42 tests) passes with no type errors, and the run is noticeably faster after removing thevi.waitForpolling.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Release Notes