test(query-devtools/TanstackQueryDevtools): replace placeholder with 'mount' and 'unmount' lifecycle tests#10639
Conversation
|
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)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new Vitest test suite for ChangesTest Suite Replacement
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 |
|
View your CI Pipeline Execution ↗ for commit 03095cb
☁️ 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. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/query-devtools/src/__tests__/TanstackQueryDevtools.test.tsx (1)
8-15: ⚡ Quick winConsider adding an
afterEachhook for cleanup.While each test gets a fresh
devtoolsinstance, adding cleanup inafterEachwould make the suite more robust—especially if a test fails partway through and leaves resources mounted. Additionally, TanStack Query best practice recommends clearing theQueryClientafter tests.🧹 Proposed cleanup hook
}) + + afterEach(() => { + // Safe cleanup even if test fails partway + try { + devtools.unmount() + } catch { + // Already unmounted or never mounted + } + }) describe('mount', () => {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/query-devtools/src/__tests__/TanstackQueryDevtools.test.tsx` around lines 8 - 15, Create a shared QueryClient variable and add an afterEach cleanup that clears the client and unmounts/disposes the devtools: move new QueryClient() out of the TanstackQueryDevtools constructor into a top-level queryClient variable used in beforeEach, then add afterEach which calls await queryClient.clear(); if (devtools?.unmount) call devtools.unmount(); else if (devtools?.dispose) call devtools.dispose(); finally set devtools = undefined to ensure no mounted resources remain (referencing queryClient and devtools/TanstackQueryDevtools).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/query-devtools/src/__tests__/TanstackQueryDevtools.test.tsx`:
- Around line 8-15: Create a shared QueryClient variable and add an afterEach
cleanup that clears the client and unmounts/disposes the devtools: move new
QueryClient() out of the TanstackQueryDevtools constructor into a top-level
queryClient variable used in beforeEach, then add afterEach which calls await
queryClient.clear(); if (devtools?.unmount) call devtools.unmount(); else if
(devtools?.dispose) call devtools.dispose(); finally set devtools = undefined to
ensure no mounted resources remain (referencing queryClient and
devtools/TanstackQueryDevtools).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 06108795-ed78-4107-8428-49ff7a7f2dd5
📒 Files selected for processing (2)
packages/query-devtools/src/__tests__/TanstackQueryDevtools.test.tsxpackages/query-devtools/src/__tests__/devtools.test.tsx
💤 Files with no reviewable changes (1)
- packages/query-devtools/src/tests/devtools.test.tsx
…'mount' and 'unmount' lifecycle tests
d7bf361 to
03095cb
Compare
size-limit report 📦
|
🎯 Changes
Replace the placeholder test (
expect(1).toBe(1)) with the first real lifecycle tests for theTanstackQueryDevtoolscore class.src/__tests__/devtools.test.tsx(placeholder)src/__tests__/TanstackQueryDevtools.test.tsxwith 5 cases coveringmount/unmountlifecycle and guard behavior:mount: succeeds on a provided element / throws on double mountunmount: allows remounting / throws when called before mount / throws on double unmountSetter contract and reactive UI behavior are intentionally out of scope for this PR — they will be covered in follow-up PRs.
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit