-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
test(react-query/ssr): add 'useIsFetching' test for SSR #9994
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/ssr): add 'useIsFetching' test for SSR #9994
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.