Skip to content

test(query-core/queryObserver): add test for not tracking error prop when 'throwOnError' is not set#10517

Merged
sukvvon merged 1 commit intomainfrom
test/query-core-queryObserver-throwOnError
Apr 19, 2026
Merged

test(query-core/queryObserver): add test for not tracking error prop when 'throwOnError' is not set#10517
sukvvon merged 1 commit intomainfrom
test/query-core-queryObserver-throwOnError

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 19, 2026

🎯 Changes

Add a test to verify that error prop is not auto-added to trackedProps when throwOnError is not set.

This covers the else branch of if (this.options.throwOnError) in queryObserver.ts — complementing the existing should track error prop when throwOnError is true test that covers the if branch.

✅ 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 a test verifying QueryObserver behavior when error tracking is not enabled and only the data property is manually tracked.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 19, 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: 751d4db2-0806-48ba-9dc9-5f7fb0c2e3cd

📥 Commits

Reviewing files that changed from the base of the PR and between 69d2757 and bb6d9f0.

📒 Files selected for processing (1)
  • packages/query-core/src/__tests__/queryObserver.test.tsx

📝 Walkthrough

Walkthrough

A new test was added to queryObserver.test.tsx that verifies QueryObserver does not automatically track the error property when created without throwOnError. The test tracks only the data prop and confirms that subscriber notifications are not triggered when only untracked properties change.

Changes

Cohort / File(s) Summary
QueryObserver Error Tracking Test
packages/query-core/src/__tests__/queryObserver.test.tsx
Added test case verifying that error property changes do not trigger subscriber notifications when error tracking is not explicitly enabled and only data prop is tracked.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

package: query-core

Poem

🐰 A test hops in with careful thought,
To check which errors should be caught,
When data dances, error stays,
Untracked through the observer's gaze!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a test for the else branch of throwOnError logic in queryObserver.
Description check ✅ Passed The description follows the template structure with all required sections completed: Changes, Checklist, and Release Impact are all present and properly filled out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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/query-core-queryObserver-throwOnError

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 19, 2026

View your CI Pipeline Execution ↗ for commit bb6d9f0

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m View ↗

☁️ Nx Cloud last updated this comment at 2026-04-19 07:27:52 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 19, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: bb6d9f0

@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 self-assigned this Apr 19, 2026
@sukvvon sukvvon merged commit 430e988 into main Apr 19, 2026
13 of 14 checks passed
@sukvvon sukvvon deleted the test/query-core-queryObserver-throwOnError branch April 19, 2026 07:52
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