Skip to content

test({react,preact}-query/useMutation): add 'throwOnError' false case tests#10485

Merged
sukvvon merged 1 commit intomainfrom
test/react-preact-query-useMutation-throwOnError-false
Apr 13, 2026
Merged

test({react,preact}-query/useMutation): add 'throwOnError' false case tests#10485
sukvvon merged 1 commit intomainfrom
test/react-preact-query-useMutation-throwOnError-false

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 13, 2026

🎯 Changes

  • Add 3 runtime tests for useMutation throwOnError false cases in both react-query and preact-query:
    • should not throw an error when throwOnError is set to false: explicitly set to false
    • should not throw an error when throwOnError is a function that returns false: function returning false
    • should not throw an error when throwOnError is not set: default value (false)
  • Complements existing tests that verify throwOnError: true and throwOnError: () => true behavior

✅ 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 comprehensive test coverage for mutation error handling across preact and react query implementations. Tests validate that when mutations fail, errors are properly captured in the component state and displayed to users across multiple error throwing configurations—when disabled, when conditionally applied, or when the option is omitted.

@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: b3737498-f93d-45de-8c01-f7f4f0d738aa

📥 Commits

Reviewing files that changed from the base of the PR and between ffa4164 and a3def7c.

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

📝 Walkthrough

Walkthrough

Added three test cases to both preact-query and react-query test suites verifying that useMutation error handling respects the throwOnError configuration option. Tests confirm errors are captured in component state rather than thrown when the option is false, a function returning false, or omitted entirely.

Changes

Cohort / File(s) Summary
Mutation Error Handling Tests
packages/preact-query/src/__tests__/useMutation.test.tsx, packages/react-query/src/__tests__/useMutation.test.tsx
Added three test cases verifying throwOnError behavior: errors do not propagate as thrown exceptions when set to false, a function returning false, or left unset; errors render via component state instead.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Three test cases hopped along,
To check if errors play along,
No throws, just states so clear,
The mutations need not fear! 🎉

🚥 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 title clearly and concisely describes the main change: adding tests for the 'throwOnError' false case in both react-query and preact-query useMutation.
Description check ✅ Passed The description follows the required template with all sections completed: Changes section details the three new tests added, Checklist items are marked, and Release Impact correctly identifies this as dev-only.

✏️ 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-throwOnError-false

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 a3def7c

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

☁️ Nx Cloud last updated this comment at 2026-04-13 16:40:41 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@10485

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: a3def7c

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

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

@sukvvon sukvvon merged commit 9bd8b25 into main Apr 13, 2026
10 checks passed
@sukvvon sukvvon deleted the test/react-preact-query-useMutation-throwOnError-false branch April 13, 2026 16:45
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