Skip to content

test({react,preact}-query/usePrefetchQuery): use the '.then()' convention consistently#11091

Merged
sukvvon merged 3 commits into
TanStack:mainfrom
Antoliny0919:use-then-convention
Jul 24, 2026
Merged

test({react,preact}-query/usePrefetchQuery): use the '.then()' convention consistently#11091
sukvvon merged 3 commits into
TanStack:mainfrom
Antoliny0919:use-then-convention

Conversation

@Antoliny0919

@Antoliny0919 Antoliny0919 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

🎯 Changes

Two queryFn.mockImplementationOnce overrides in usePrefetchQuery.test.tsx are still written with async/await, while the base implementation of the very same queryFn already uses.then().
#10399 / #10400 converted the mockImplementation of the shared generateQueryFn helper in these files, so these look like leftovers from that pass , they appear to be the last mockImplementationOnce(async ...) in the repo.

The rejection happens strictly after sleep(10) resolves, so the timing is unchanged.
Would it make sense to switch them to match the convention 🤔

✅ 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
    • Updated prefetch error-handling tests to more reliably simulate delayed server failures.
    • Preserved coverage for failed-query behavior, retry handling, and recovery flows.

@coderabbitai

coderabbitai Bot commented Jul 21, 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: 7cdf0607-052d-416b-a8e6-ae46b6ab9e5a

📥 Commits

Reviewing files that changed from the base of the PR and between 181ea82 and d8bd850.

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

📝 Walkthrough

Walkthrough

Updated React and Preact usePrefetchQuery error tests to produce delayed query failures through promise chains instead of async/await mocks. Test expectations, component wiring, and recovery behavior remain unchanged.

Changes

Prefetch error test updates

Layer / File(s) Summary
Promise-chain error mocks
packages/{react-query,preact-query}/src/__tests__/usePrefetchQuery.test.tsx
The two failing queryFn mocks in each package now return sleep(10).then(...) and throw the same server error inside the callback.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: sukvvon

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the test-only switch from async/await to .then() in usePrefetchQuery tests.
Description check ✅ Passed The description matches the template with Changes, Checklist, and Release Impact, and the key details are filled in.
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 unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@nx-cloud

nx-cloud Bot commented Jul 24, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit cb6eb48

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

☁️ Nx Cloud last updated this comment at 2026-07-24 03:29:08 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jul 24, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 46dca37

@sukvvon
sukvvon merged commit a3b0612 into TanStack:main Jul 24, 2026
9 checks passed
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.

2 participants