Conversation
…eforeEach' for per-test isolation
|
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 (2)
📝 WalkthroughWalkthroughMoved test-level QueryCache/QueryClient initialization into beforeEach across preact/react/solid query packages and centralized cleanup by calling queryClient.clear() in afterEach (after restoring real timers) to ensure per-test client/cache isolation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 57ec1bc
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
size-limit report 📦
|
…' for per-test isolation
…in 'useQuery' and 'useMutation'
…in 'ssr' and 'suspense'
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/react-query/src/__tests__/ssr.test.tsx (1)
30-33: Consider removing redundantqueryCache.clear()calls within individual tests.With
queryClient.clear()now called inafterEach, the individualqueryCache.clear()calls at the end of each test case (lines 60, 77, 108, 140, 179, 210, 252, 272, 290) are redundant sinceQueryClient.clear()already invokesqueryCache.clear()internally. Removing these would improve code clarity and consistency with other test files in this PR.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react-query/src/__tests__/ssr.test.tsx` around lines 30 - 33, Remove the redundant queryCache.clear() calls at the end of individual tests because afterEach already calls queryClient.clear(), which internally clears the cache; search for and delete calls to queryCache.clear() in the ssr.test.tsx tests (they appear after individual it/test blocks) and rely on the existing afterEach that calls queryClient.clear() and vi.useRealTimers().packages/preact-query/src/__tests__/ssr.test.tsx (1)
28-31: Consider removing redundantqueryCache.clear()calls within individual tests.Since
queryClient.clear()inafterEachalready invokesqueryCache.clear()internally (as shown inQueryClient.clear()implementation atpackages/query-core/src/queryClient.ts:644-648), the individualqueryCache.clear()calls at the end of each test (lines 58, 75, 106, 138, 156, 195) are now redundant and can be removed for cleaner test code.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/preact-query/src/__tests__/ssr.test.tsx` around lines 28 - 31, The test suite already calls queryClient.clear() in the afterEach hook (via afterEach(() => { vi.useRealTimers(); queryClient.clear(); })), which internally calls queryCache.clear(); remove the redundant explicit queryCache.clear() calls found at the end of individual tests (the trailing queryCache.clear() invocations within the tests) so the cleanup is handled centrally by queryClient.clear(); keep the afterEach hook as-is and delete only the per-test queryCache.clear() calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/preact-query/src/__tests__/ssr.test.tsx`:
- Around line 28-31: The test suite already calls queryClient.clear() in the
afterEach hook (via afterEach(() => { vi.useRealTimers(); queryClient.clear();
})), which internally calls queryCache.clear(); remove the redundant explicit
queryCache.clear() calls found at the end of individual tests (the trailing
queryCache.clear() invocations within the tests) so the cleanup is handled
centrally by queryClient.clear(); keep the afterEach hook as-is and delete only
the per-test queryCache.clear() calls.
In `@packages/react-query/src/__tests__/ssr.test.tsx`:
- Around line 30-33: Remove the redundant queryCache.clear() calls at the end of
individual tests because afterEach already calls queryClient.clear(), which
internally clears the cache; search for and delete calls to queryCache.clear()
in the ssr.test.tsx tests (they appear after individual it/test blocks) and rely
on the existing afterEach that calls queryClient.clear() and vi.useRealTimers().
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f27c74bf-54fa-46c1-8561-44958aa30bbe
📒 Files selected for processing (30)
packages/preact-query/src/__tests__/QueryResetErrorBoundary.test.tsxpackages/preact-query/src/__tests__/fine-grained-persister.test.tsxpackages/preact-query/src/__tests__/ssr.test.tsxpackages/preact-query/src/__tests__/suspense.test.tsxpackages/preact-query/src/__tests__/useInfiniteQuery.test.tsxpackages/preact-query/src/__tests__/useMutation.test.tsxpackages/preact-query/src/__tests__/usePrefetchInfiniteQuery.test.tsxpackages/preact-query/src/__tests__/usePrefetchQuery.test.tsxpackages/preact-query/src/__tests__/useQueries.test.tsxpackages/preact-query/src/__tests__/useQuery.test.tsxpackages/preact-query/src/__tests__/useSuspenseInfiniteQuery.test.tsxpackages/preact-query/src/__tests__/useSuspenseQuery.test.tsxpackages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsxpackages/react-query/src/__tests__/fine-grained-persister.test.tsxpackages/react-query/src/__tests__/ssr.test.tsxpackages/react-query/src/__tests__/suspense.test.tsxpackages/react-query/src/__tests__/useInfiniteQuery.test.tsxpackages/react-query/src/__tests__/useMutation.test.tsxpackages/react-query/src/__tests__/usePrefetchInfiniteQuery.test.tsxpackages/react-query/src/__tests__/usePrefetchQuery.test.tsxpackages/react-query/src/__tests__/useQueries.test.tsxpackages/react-query/src/__tests__/useQuery.test.tsxpackages/react-query/src/__tests__/useSuspenseInfiniteQuery.test.tsxpackages/react-query/src/__tests__/useSuspenseQuery.test.tsxpackages/solid-query/src/__tests__/suspense.test.tsxpackages/solid-query/src/__tests__/transition.test.tsxpackages/solid-query/src/__tests__/useInfiniteQuery.test.tsxpackages/solid-query/src/__tests__/useMutation.test.tsxpackages/solid-query/src/__tests__/useQueries.test.tsxpackages/solid-query/src/__tests__/useQuery.test.tsx
… calls in individual tests
🎯 Changes
Move
queryClientandqueryCachefrom describe-level constants tobeforeEach/afterEachfor per-test isolation acrossreact-query,preact-query, andsolid-querytest files.Files changed:
{react,preact}-query:QueryResetErrorBoundary,fine-grained-persister,ssr,suspense,useInfiniteQuery,useMutation,usePrefetchInfiniteQuery,usePrefetchQuery,useQueries,useQuery,useSuspenseInfiniteQuery,useSuspenseQuerysolid-query:suspense,transition,useInfiniteQuery,useMutation,useQueries,useQueryEach test now gets a fresh
QueryClientandQueryCacheinstance, withqueryClient.clear()called inafterEachfor explicit cleanup.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit