Skip to content

test(query-core/queryObserver): add test for promise not rejecting when 'experimental_prefetchInRender' is enabled - #10887

Merged
sukvvon merged 1 commit into
mainfrom
test/query-core-observer-prefetch-in-render-promise
Jun 5, 2026
Merged

test(query-core/queryObserver): add test for promise not rejecting when 'experimental_prefetchInRender' is enabled#10887
sukvvon merged 1 commit into
mainfrom
test/query-core-observer-prefetch-in-render-promise

Conversation

@sukvvon

@sukvvonsukvvon commented Jun 5, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Adds a unit test for QueryObserver.trackResult covering the case where experimental_prefetchInRender is enabled: reading the tracked promise resolves with the data instead of rejecting.

This complements the existing test that asserts the promise rejects when the flag is disabled, covering the other side of the guard.

✅ 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 that enabling experimental prefetch-in-render causes a tracked query result's promise to resolve (instead of reject) when the observer completes.

@coderabbitai

coderabbitaiBot commented Jun 5, 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: 7ed9cf9c-3400-431e-a841-d3d3e0f0e775

📥 Commits

Reviewing files that changed from the base of the PR and between 21aa19d and 94e0213.

📒 Files selected for processing (1)
  • packages/query-core/src/__tests__/queryObserver.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/query-core/src/tests/queryObserver.test.tsx

📝 Walkthrough

Walkthrough

Adds a test to queryObserver.test.tsx that enables experimental_prefetchInRender, subscribes a QueryObserver, calls trackResult(...).promise, advances fake timers, and asserts the promise resolves to 'data'.

Changes

QueryObserver Prefetch Test

Layer / File(s)Summary
QueryObserver prefetchInRender trackResult resolution test
packages/query-core/src/__tests__/queryObserver.test.tsx
Test creates a QueryClient with experimental_prefetchInRender enabled, subscribes a QueryObserver, calls trackResult on the current result, advances fake timers until completion, and asserts the tracked promise resolves to 'data'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TanStack/query#10249: Related test coverage for trackResult().promise behavior under the experimental_prefetchInRender feature flag.

Suggested labels

package: query-core

Poem

🐰 Timers tick and promises hum,
A tracked result resolves to 'data' — yum!
Prefetch in render, tests align,
Rabbity cheers for async fine. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately and specifically describes the test being added, highlighting the key condition (experimental_prefetchInRender enabled) and expected behavior (promise not rejecting).
Description check✅ PassedThe description follows the repository template with all required sections completed, including a clear explanation of changes, a filled checklist, and proper release impact designation.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

✏️ 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-observer-prefetch-in-render-promise

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

@nx-cloud

nx-cloudBot commented Jun 5, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit b91058c

CommandStatusDurationResult
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded4m 44sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 45sView ↗

☁️ Nx Cloud last updated this comment at 2026-06-05 13:58:42 UTC

@github-actions

github-actionsBot commented Jun 5, 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.

@sukvvonsukvvon self-assigned this Jun 5, 2026
@pkg-pr-new

pkg-pr-newBot commented Jun 5, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 94e0213

@github-actions

github-actionsBot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
react full12.11 KB (0%)
react minimal9.08 KB (0%)

@sukvvon
sukvvonforce-pushed the test/query-core-observer-prefetch-in-render-promise branch from b91058c to 21aa19dCompareJune 5, 2026 13:42
…en 'experimental_prefetchInRender' is enabled
@sukvvon
sukvvonforce-pushed the test/query-core-observer-prefetch-in-render-promise branch from 21aa19d to 94e0213CompareJune 5, 2026 13:53
@sukvvon
sukvvon merged commit bd0a264 into mainJun 5, 2026
9 checks passed
@sukvvon
sukvvon deleted the test/query-core-observer-prefetch-in-render-promise branch June 5, 2026 14:03
Sign up for freeto 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

@sukvvon