Skip to content

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

Merged
sukvvon merged 4 commits into
mainfrom
test/react-preact-query-then-convention
Jul 20, 2026
Merged

test({react,preact}-query): use the '.then()' convention consistently#11085
sukvvon merged 4 commits into
mainfrom
test/react-preact-query-then-convention

Conversation

@sukvvon

@sukvvon sukvvon commented Jul 20, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Several queryFn/mutationFn implementations were left as async/await even though the surrounding tests in each file overwhelmingly use the .then() convention. This PR converts the remaining cases where a side effect (counter increment, .push(), throw) happens strictly after await sleep(...), so it can be expressed as sleep(...).then(() => { ... }) without changing execution order.

Cases where a side effect happens before sleep(...) are intentionally left as async/await, since converting them would require pulling the side effect out of the .then() callback and wouldn't shorten or clarify the code.

  • useInfiniteQuery: converted 2 queryFns in both react-query and preact-query
  • useMutation: converted several mutationFns (removed unnecessary async on already-.then()-based functions, converted sleep-then-effect cases) in both packages
  • useQueries: converted queryFns with post-sleep side effects, removed unnecessary async on functions with no await
  • useQuery (+ useQuery.promise, useSuspenseQuery in react-query): converted queryFns with post-sleep side effects/throws

✅ 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 asynchronous test scenarios across query, mutation, infinite query, suspense, and multi-query behavior.
    • Preserved coverage for refetching, retries, error handling, pagination, promise combinations, and rendering behavior.
    • Standardized test promise handling without changing expected results or assertions.

@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 20, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 79c2287

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

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

@nx-cloud

nx-cloud Bot commented Jul 20, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 79c2287

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

☁️ Nx Cloud last updated this comment at 2026-07-20 01:20:55 UTC

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Test-only refactors replace async/await query and mutation functions with explicit sleep(...).then(...) Promise chains across React and Preact packages, preserving existing return values, delays, counters, pagination, retries, and rejection behavior.

Changes

Promise-chain test fixture refactor

Layer / File(s) Summary
Preact query fixture conversions
packages/preact-query/src/__tests__/useInfiniteQuery.test.tsx, useQueries.test.tsx, useQuery.test.tsx
Query functions now return Promise chains while preserving query results, pagination fields, counters, refetch behavior, and error paths.
Preact mutation fixture conversions
packages/preact-query/src/__tests__/useMutation.test.tsx
Mutation fixtures use Promise chains for callback errors, retries, conditional outcomes, custom clients, and Promise combinators.
React query fixture conversions
packages/react-query/src/__tests__/useInfiniteQuery.test.tsx, useQueries.test.tsx, useQuery.promise.test.tsx, useQuery.test.tsx, useSuspenseQuery.test.tsx
Query and suspense fixtures remove async wrappers while retaining existing results, errors, timing, and state-transition scenarios.
React mutation fixture conversions
packages/react-query/src/__tests__/useMutation.test.tsx
Mutation fixtures preserve callback, retry, error, custom-client, and parallel mutation behavior through explicit Promise chains.

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

Possibly related PRs

Suggested labels: package: react-query, package: preact-query

Suggested reviewers: tkdodo

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately summarizes the main change: standardizing test functions to use the .then() style.
Description check ✅ Passed The description matches the template and covers changes, checklist, and release impact with clear detail.
✨ 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-then-convention

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

@sukvvon
sukvvon merged commit 6d55b07 into main Jul 20, 2026
11 of 12 checks passed
@sukvvon
sukvvon deleted the test/react-preact-query-then-convention branch July 20, 2026 10:38
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