Skip to content

test({react,preact}-query/useMutation): add callback tests when 'useMutation' has no callbacks - #10489

Merged
sukvvon merged 2 commits into
mainfrom
test/react-preact-query-useMutation-no-hook-callbacks
Apr 13, 2026
Merged

test({react,preact}-query/useMutation): add callback tests when 'useMutation' has no callbacks#10489
sukvvon merged 2 commits into
mainfrom
test/react-preact-query-useMutation-no-hook-callbacks

Conversation

@sukvvon

@sukvvonsukvvon commented Apr 13, 2026

Copy link
Copy Markdown
Member

🎯 Changes

  • Add 10 runtime tests for useMutation callback behavior when useMutation has no hook-level callbacks in both react-query and preact-query:
    • Combination callbacks:
      • should call mutate callbacks when useMutation has no callbacks (onSuccess + onSettled)
      • should call mutateAsync callbacks when useMutation has no callbacks (onSuccess + onSettled)
      • should call mutate error callbacks when useMutation has no callbacks (onError + onSettled)
      • should call mutateAsync error callbacks when useMutation has no callbacks (onError + onSettled)
    • Single callbacks:
      • should call only mutate onSuccess when useMutation has no callbacks
      • should call only mutate onError when useMutation has no callbacks
      • should call only mutate onSettled when useMutation has no callbacks
      • should call only mutateAsync onSuccess when useMutation has no callbacks
      • should call only mutateAsync onError when useMutation has no callbacks
      • should call only mutateAsync onSettled when useMutation has no callbacks

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for useMutation callback execution across success, error, and combined callback scenarios in both React and Preact implementations.

@coderabbitai

coderabbitaiBot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66ba1487-7d02-400e-857d-781cc39e6360

📥 Commits

Reviewing files that changed from the base of the PR and between 1b661b3 and a464def.

📒 Files selected for processing (2)
  • packages/preact-query/src/__tests__/useMutation.test.tsx
  • packages/react-query/src/__tests__/useMutation.test.tsx

📝 Walkthrough

Walkthrough

Added 326 lines of test cases to both React Query and Preact Query packages verifying useMutation callback execution (onSuccess, onError, onSettled) for per-invocation callbacks when no hook-level defaults are configured, covering success and failure scenarios for both mutate and mutateAsync methods.

Changes

Cohort / File(s)Summary
Preact Query useMutation Tests
packages/preact-query/src/__tests__/useMutation.test.tsx
Added 326 lines of test cases verifying per-invocation callback behavior for mutate and mutateAsync, including success/error scenarios with individual and combined callbacks (onSuccess, onError, onSettled).
React Query useMutation Tests
packages/react-query/src/__tests__/useMutation.test.tsx
Added 326 lines of test cases verifying per-invocation callback behavior for mutate and mutateAsync, including success/error scenarios with individual and combined callbacks (onSuccess, onError, onSettled).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Tests now bloom in pairs so bright,
React and Preact, side by side,
Callbacks dancing left and right,
Success and errors verified! ✨
A rabbit's hop through mutation's way. 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the main change: adding callback tests for useMutation when no hook-level callbacks are present, covering both react-query and preact-query packages.
Description check✅ PassedThe description follows the template structure with detailed changes listed, completed checklist, and correctly marked as docs/CI/dev-only without requiring a changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/react-preact-query-useMutation-no-hook-callbacks

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloudBot commented Apr 13, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a464def

CommandStatusDurationResult
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded2m 41sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded1sView ↗

☁️ Nx Cloud last updated this comment at 2026-04-13 18:20:32 UTC

@github-actions

github-actionsBot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10489

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10489

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10489

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@10489

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10489

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10489

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10489

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@10489

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@10489

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10489

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10489

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@10489

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@10489

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10489

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10489

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@10489

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10489

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10489

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@10489

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10489

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10489

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@10489

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10489

commit: a464def

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
react full11.99 KB (0%)
react minimal9.02 KB (0%)

@sukvvon
sukvvon merged commit 792d3a5 into mainApr 13, 2026
8 checks passed
@sukvvon
sukvvon deleted the test/react-preact-query-useMutation-no-hook-callbacks branch April 13, 2026 18:26
Ephem pushed a commit to Ephem/react-query that referenced this pull request Apr 23, 2026
…utation' has no callbacks (TanStack#10489)
* test({react,preact}-query/useMutation): add callback tests when 'useMutation' has no callbacks
* ci: apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@sukvvon