Skip to content

test({react,preact,solid}-query/useMutation): improve callback assertions with 'toHaveBeenNthCalledWith'#11050

Merged
sukvvon merged 1 commit into
mainfrom
test/mutation-callback-nth
Jul 11, 2026
Merged

test({react,preact,solid}-query/useMutation): improve callback assertions with 'toHaveBeenNthCalledWith'#11050
sukvvon merged 1 commit into
mainfrom
test/mutation-callback-nth

Conversation

@sukvvon

@sukvvon sukvvon commented Jul 11, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Applies the same strengthening as #9630 (svelte-query) to the react/preact/solid useMutation callback tests. In the "multiple mutate calls" tests, the mutate button is clicked three times sequentially, so onSuccess/onSettled/onError fire in a deterministic order with distinct arguments (1, 2, 3).

The assertions used order-agnostic toHaveBeenCalledWith(1)/(2)/(3), which would still pass if the callbacks fired in the wrong order. Switching to toHaveBeenNthCalledWith(1, 1)/(2, 2)/(3, 3) pins each call to its position, matching the intent of "the correct arguments after each mutate".

✅ Checklist

🚀 Release Impact

  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Strengthened coverage for mutation callbacks across supported frameworks.
    • Tests now verify that success, error, and completion callbacks run in the expected order for multiple consecutive mutations.
    • Added checks to ensure each callback receives the result or error associated with the correct mutation attempt.

@nx-cloud

nx-cloud Bot commented Jul 11, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 5eef12e

Command Status Duration Result
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 49s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-11 06:36:06 UTC

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dd61a005-bfe7-4ee3-96aa-c77d92248eeb

📥 Commits

Reviewing files that changed from the base of the PR and between 72e90c8 and 5eef12e.

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

📝 Walkthrough

Walkthrough

Mutation callback tests for Preact, React, and Solid now verify that success, error, and settled callbacks receive arguments in the expected invocation order across three mutation attempts.

Changes

Mutation callback order

Layer / File(s) Summary
Ordered callback assertions
packages/*-query/src/__tests__/useMutation.test.tsx
Success and failure tests use toHaveBeenNthCalledWith to verify callback arguments for the first, second, and third mutation attempts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: stricter useMutation callback assertions using toHaveBeenNthCalledWith across react, preact, and solid tests.
Description check ✅ Passed The description follows the required template and covers changes, checklist, and release impact with relevant details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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/mutation-callback-nth

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

@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.

@sukvvon sukvvon self-assigned this Jul 11, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 11, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11050

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 5eef12e

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.13 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon sukvvon merged commit 0a852e0 into main Jul 11, 2026
11 of 12 checks passed
@sukvvon sukvvon deleted the test/mutation-callback-nth branch July 11, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant