test(react-query/ssr): add 'useIsFetching' test for SSR#9994
test(react-query/ssr): add 'useIsFetching' test for SSR#9994TkDodo merged 1 commit intoTanStack:mainfrom
Conversation
|
📝 WalkthroughWalkthroughA new SSR test case was added to validate the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 29aa8fb
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/react-query/src/__tests__/ssr.test.tsx (1)
178-207: Excellent test coverage foruseIsFetchingin SSR!The test correctly validates that
useIsFetchingreturns 0 after a prefetch completes in server-side rendering. The logic follows the established pattern: prefetch → wait → render → assert.Consider wrapping
queryFnwithvi.fn()for consistency with similar tests (lines 33, 78, 141) and to add a call-count assertion:Optional refactor for consistency
- const queryFn = () => sleep(10).then(() => 'data') + const queryFn = vi.fn(() => sleep(10).then(() => 'data'))Then add after line 204:
expect(markup).toContain('data') expect(markup).toContain('isFetching: 0') + expect(queryFn).toHaveBeenCalledTimes(1)This would verify that the query was prefetched exactly once and not re-fetched during render.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/react-query/src/__tests__/ssr.test.tsx
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-22T09:06:05.219Z
Learnt from: sukvvon
Repo: TanStack/query PR: 9892
File: packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx:331-335
Timestamp: 2025-11-22T09:06:05.219Z
Learning: In TanStack/query test files, when a queryFn contains side effects (e.g., setting flags for test verification), prefer async/await syntax for clarity; when there are no side effects, prefer the .then() pattern for conciseness.
Applied to files:
packages/react-query/src/__tests__/ssr.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (1)
packages/react-query/src/__tests__/ssr.test.tsx (1)
10-10: LGTM! Clean import addition.The
useIsFetchingimport is correctly placed and necessary for the new test case.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9994 +/- ##
===========================================
+ Coverage 45.89% 83.91% +38.02%
===========================================
Files 200 26 -174
Lines 8437 373 -8064
Branches 1933 110 -1823
===========================================
- Hits 3872 313 -3559
+ Misses 4116 51 -4065
+ Partials 449 9 -440
🚀 New features to boost your workflow:
|
🎯 Changes
Add
useIsFetchingtest for SSR inssr.test.tsx.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
useIsFetchinghook is now exported from the public API and available for use.Tests
useIsFetchingto validate fetching state behavior.✏️ Tip: You can customize this high-level summary in your review settings.