Skip to content

test({react,preact}-query/useMutation): add 'mutate' callback override tests#10486

Merged
sukvvon merged 1 commit intomainfrom
test/react-preact-query-useMutation-mutate-callback-override
Apr 13, 2026
Merged

test({react,preact}-query/useMutation): add 'mutate' callback override tests#10486
sukvvon merged 1 commit intomainfrom
test/react-preact-query-useMutation-mutate-callback-override

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 13, 2026

🎯 Changes

  • Add 2 runtime tests for useMutation mutate callback override in both react-query and preact-query:
    • should be able to override the error callbacks when using mutate: verifies onError and onSettled callbacks are called in order (useMutation → mutate)
    • should be able to override the settled callbacks when using mutate: verifies onSuccess and onSettled callbacks are called in order (useMutation → mutate)
  • Complements existing tests that verify the same behavior with mutateAsync (line 266, 316)

✅ 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
    • Added test coverage for useMutation callback execution order in both React Query and Preact Query, verifying correct callback sequencing for successful and failed mutations with per-call option overrides.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ca2e181-123a-4398-bc4d-607424a329a9

📥 Commits

Reviewing files that changed from the base of the PR and between 9bd8b25 and 888b950.

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

📝 Walkthrough

Walkthrough

Two test suites now validate useMutation callback execution order when using per-call option overrides in both preact-query and react-query packages, covering both success and failure scenarios.

Changes

Cohort / File(s) Summary
useMutation Callback Ordering Tests
packages/preact-query/src/__tests__/useMutation.test.tsx, packages/react-query/src/__tests__/useMutation.test.tsx
Added test coverage verifying that hook-level onError/onSuccess/onSettled handlers execute before per-call mutate option overrides in both rejection and resolution paths, using fake timers to drive async completion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Callbacks in order, a rabbit's delight,
First the hook-level handlers take flight,
Then per-call options follow with grace,
Each test ensures they stay in their place!
🧪✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Title check ✅ Passed The pull request title clearly summarizes the main change: adding 'mutate' callback override tests for both react-query and preact-query useMutation hooks.
Description check ✅ Passed The pull request description fully follows the repository template with completed 🎯 Changes section, checked ✅ Checklist items, and 🚀 Release Impact assessment indicating this is a docs/CI/dev-only change.

✏️ 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-mutate-callback-override

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 13, 2026

View your CI Pipeline Execution ↗ for commit 888b950

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 46s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-13 17:00:26 UTC

@github-actions
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

pkg-pr-new bot commented Apr 13, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 888b950

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.99 KB (0%)
react minimal 9.02 KB (0%)

Sign up for free to 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