test(query-core/queryObserver): add test for rejecting promise when 'experimental_prefetchInRender' is disabled#10249
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds two identical tests to QueryObserver's test suite asserting that when Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit df8f53a
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/query-core/src/__tests__/queryObserver.test.tsx (1)
1399-1403: Assert ontracked.promisedirectly to make the test preciseThis keeps the assertion aligned with the behavior under test (
trackResult) and avoids the extravoidaccess pattern.Proposed diff
- void tracked.promise - - await expect(result.promise).rejects.toThrow( + await expect(tracked.promise).rejects.toThrow( 'experimental_prefetchInRender feature flag is not enabled', )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/query-core/src/__tests__/queryObserver.test.tsx` around lines 1399 - 1403, The test currently uses a redundant `void tracked.promise` and then asserts `result.promise`; update it to assert `tracked.promise` directly to accurately test the behavior of `trackResult` — remove the `void tracked.promise` line and change the expectation from `expect(result.promise).rejects.toThrow(...)` to `expect(tracked.promise).rejects.toThrow(...)`, keeping the same error message assertion.
🤖 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/query-core/src/__tests__/queryObserver.test.tsx`:
- Around line 1399-1403: The test currently uses a redundant `void
tracked.promise` and then asserts `result.promise`; update it to assert
`tracked.promise` directly to accurately test the behavior of `trackResult` —
remove the `void tracked.promise` line and change the expectation from
`expect(result.promise).rejects.toThrow(...)` to
`expect(tracked.promise).rejects.toThrow(...)`, keeping the same error message
assertion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: dbcc6ceb-e941-4f52-9dd3-c9788ca19816
📒 Files selected for processing (1)
packages/query-core/src/__tests__/queryObserver.test.tsx
6bc99ca to
bcbaa6d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/query-core/src/__tests__/queryObserver.test.tsx`:
- Around line 1381-1402: The test creates a local QueryClient instance
(queryClient2) but never clears it; add cleanup by calling await
queryClient2.clear() (or queryClient2.clear() in a finally block) at the end of
the test so the QueryClient is torn down after the assertions; locate the test
that instantiates QueryClient(queryClient2) and insert the clear call (using the
same queryClient2 identifier) so resources are released.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 72235061-8450-47e4-9bb4-bba61e9bae7e
📒 Files selected for processing (1)
packages/query-core/src/__tests__/queryObserver.test.tsx
…experimental_prefetchInRender' is disabled
bcbaa6d to
df8f53a
Compare
🎯 Changes
Add a test for
queryObserver.tslines 272-277 —trackResultrejecting the pending thenable whenexperimental_prefetchInRenderis disabled and.promiseis accessed.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit