-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
test(react-query/ssr): add 'useMutation' and 'useMutationState' tests for SSR #9995
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
base: main
Are you sure you want to change the base?
Conversation
|
📝 WalkthroughWalkthroughAdds SSR tests for mutation hooks and exposes Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
Comment |
|
View your CI Pipeline Execution ↗ for commit e72096f
☁️ Nx Cloud last updated this comment at |
95ae247 to
633a2e4
Compare
633a2e4 to
e72096f
Compare
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)
205-219: LGTM! Test correctly verifies useMutationState SSR behavior.The test properly validates that
useMutationStatereturns an empty array during server-side rendering.Optional: Add queryCache.clear() for consistency
For consistency with other tests in this file, consider adding
queryCache.clear()at the end of both new test cases, even though mutations don't create cache entries:expect(markup).toContain('mutationState: 0') + + queryCache.clear() })Apply the same to the
useMutationtest at line 203.
📜 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 (2)
packages/react-query/src/__tests__/ssr.test.tsx (2)
10-11: LGTM!The imports are correctly added for the new mutation hook tests.
179-203: LGTM! Test correctly verifies useMutation SSR behavior.The test properly validates that
useMutationreturns the expected idle state during server-side rendering. The assertions confirm the correct initial state without triggering the mutation function.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9995 +/- ##
===========================================
+ Coverage 45.89% 84.45% +38.55%
===========================================
Files 200 26 -174
Lines 8437 373 -8064
Branches 1933 108 -1825
===========================================
- Hits 3872 315 -3557
+ Misses 4116 49 -4067
+ Partials 449 9 -440
🚀 New features to boost your workflow:
|
🎯 Changes
Add
useMutationanduseMutationStatetests for SSR inssr.test.tsx.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.