Skip to content

test(query-core): replace 'async/await sleep' with 'sleep().then()' in test 'queryFn' and 'mutationFn' - #10435

Merged
sukvvon merged 1 commit into
mainfrom
test/query-core-replace-async-await-sleep-with-then-chaining
Apr 9, 2026
Merged

test(query-core): replace 'async/await sleep' with 'sleep().then()' in test 'queryFn' and 'mutationFn'#10435
sukvvon merged 1 commit into
mainfrom
test/query-core-replace-async-await-sleep-with-then-chaining

Conversation

@sukvvon

@sukvvonsukvvon commented Apr 9, 2026

Copy link
Copy Markdown
Member

🎯 Changes

  • Replace async () => { await sleep(N); return value } with () => sleep(N).then(() => value) in test queryFn and mutationFn
  • Applied to hydration.test.tsx, mutations.test.tsx, queriesObserver.test.tsx, query.test.tsx, queryClient.test.tsx, queryObserver.test.tsx

✅ 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
    • Refactored test implementations across multiple test suites to use promise chains instead of async/await syntax, maintaining identical test behavior and assertions.

Note: These are internal test-code updates with no impact to end-user functionality or features.

@coderabbitai

coderabbitaiBot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 20f62421-b9d2-4e51-b7bd-5db451dc7e6d

📥 Commits

Reviewing files that changed from the base of the PR and between 6b95cd8 and bb611da.

📒 Files selected for processing (6)
  • packages/query-core/src/__tests__/hydration.test.tsx
  • packages/query-core/src/__tests__/mutations.test.tsx
  • packages/query-core/src/__tests__/queriesObserver.test.tsx
  • packages/query-core/src/__tests__/query.test.tsx
  • packages/query-core/src/__tests__/queryClient.test.tsx
  • packages/query-core/src/__tests__/queryObserver.test.tsx

📝 Walkthrough

Walkthrough

This PR systematically refactors test query function implementations across multiple test files in query-core, replacing async/await with explicit promise chains using .then(), while maintaining identical timing and resolved values.

Changes

Cohort / File(s)Summary
Test Query Function Refactoring
packages/query-core/src/__tests__/hydration.test.tsx, mutations.test.tsx, queriesObserver.test.tsx, query.test.tsx, queryClient.test.tsx, queryObserver.test.tsx
Replaced async functions with await sleep(...) syntax with non-async arrow functions returning sleep(...).then(...) chains. Preserves timing semantics and resolved values across hydration, mutation, observer, and query client tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

package: query-core

Poem

🐰 Async dreams now chain so neat,
From await's grasp to .then() sweet,
Tests still sleep, no change in beat,
Just syntax sips of promise treat!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the main change: replacing async/await sleep patterns with promise chaining in test query and mutation functions across multiple test files.
Description check✅ PassedThe description follows the template structure with completed 🎯 Changes section detailing specific transformations and affected files, and 🚀 Release Impact section correctly marked as dev-only. However, the testing checklist item remains unchecked.
Docstring Coverage✅ PassedNo 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-replace-async-await-sleep-with-then-chaining

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

@nx-cloud

nx-cloudBot commented Apr 9, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit bb611da

CommandStatusDurationResult
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded55sView ↗

☁️ Nx Cloud last updated this comment at 2026-04-09 01:23:18 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.

@sukvvonsukvvon self-assigned this Apr 9, 2026
@pkg-pr-new

pkg-pr-newBot commented Apr 9, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: bb611da

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
react full11.98 KB (0%)
react minimal9.01 KB (0%)

@sukvvon
sukvvon merged commit 48c3975 into mainApr 9, 2026
13 of 14 checks passed
@sukvvon
sukvvon deleted the test/query-core-replace-async-await-sleep-with-then-chaining branch April 9, 2026 01:46
Sign up for freeto 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

@sukvvon