Conversation
… in test 'queryFn' and 'mutationFn'
📝 WalkthroughWalkthroughThis PR converts test implementations across multiple test files from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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 d2d2362
☁️ 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 📦
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/preact-query/src/__tests__/useMutation.test.tsx (1)
161-163: RedundantPromise.resolveinside.then()callback.The
.then()callback automatically wraps the returned value in a Promise, makingPromise.resolve(value)unnecessary. This should just returnvaluedirectly for consistency with the other changes in this PR.Suggested fix
- mutateFn.mockImplementation((value) => - sleep(10).then(() => Promise.resolve(value)), - ) + mutateFn.mockImplementation((value) => sleep(10).then(() => value))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/preact-query/src/__tests__/useMutation.test.tsx` around lines 161 - 163, The mock implementation for mutateFn uses Promise.resolve inside a .then callback which is redundant; update mutateFn.mockImplementation((value) => sleep(10).then(() => Promise.resolve(value))) to simply return the value from the .then callback (i.e., .then(() => value)) so the promise resolves the same way and matches the style of other tests; locate and change the mutateFn.mockImplementation call in useMutation.test.tsx.
🤖 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__/useMutation.test.tsx`:
- Around line 161-163: The mock implementation for mutateFn uses Promise.resolve
inside a .then callback which is redundant; update
mutateFn.mockImplementation((value) => sleep(10).then(() =>
Promise.resolve(value))) to simply return the value from the .then callback
(i.e., .then(() => value)) so the promise resolves the same way and matches the
style of other tests; locate and change the mutateFn.mockImplementation call in
useMutation.test.tsx.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2f567c03-2339-478d-8002-dc10b8ce68b1
📒 Files selected for processing (6)
packages/preact-query/src/__tests__/fine-grained-persister.test.tsxpackages/preact-query/src/__tests__/useMutation.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__/useSuspenseQueries.test.tsx
🎯 Changes
async () => { await sleep(N); return value }with() => sleep(N).then(() => value)in testqueryFnandmutationFnuseQuery.test.tsx,useQueries.test.tsx,useMutation.test.tsx,usePrefetchQuery.test.tsx,useSuspenseQueries.test.tsx, andfine-grained-persister.test.tsx✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit