Skip to content

test(*): resolve 'require-await' warnings in test files#10551

Merged
sukvvon merged 1 commit intomainfrom
test/fix-require-await-warnings
Apr 21, 2026
Merged

test(*): resolve 'require-await' warnings in test files#10551
sukvvon merged 1 commit intomainfrom
test/fix-require-await-warnings

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 21, 2026

🎯 Changes

Resolves the 8 @typescript-eslint/require-await warnings that existed in real test files across query-core, react-query, and solid-query. Three distinct strategies are applied depending on what each case actually needs.

Strategy 1 — async → non-async with Promise.resolve / Promise.reject

Used in queryFn callbacks whose async keyword was leftover after await was removed. The resulting function still returns a Promise<T>, so TanStack Query keeps routing the call through the async path. Semantically identical to async + throw, following the existing repo pattern (e.g. query-core/__tests__/query.test.tsx:913-916, hydration.test.tsx:198, 1285).

  • query-core/__tests__/queryObserver.test.tsx:1484, 1523 — call-count-based queryFn
  • react-query/__tests__/useQuery.test.tsx:5678async () => { count++; return \data${count}` }`
  • solid-query/__tests__/useQuery.test.tsx:5946 — same pattern as above

Strategy 2 — drop async from it callbacks that never await

Used when it(..., async () => { ... }) had no await in the body.

  • solid-query/__tests__/useQuery.test.tsx:3953 — simple render + DOM assertion
  • solid-query/__tests__/useQuery.test.tsx:5020 — simple render + hash count assertion

Strategy 3 — eslint-disable-next-line for unavoidable async function*

The streamFn passed to streamedQuery must return an AsyncIterable, and dropping async would break the type. These two call sites happen not to have any await/for await in their body (which is why eslint flags them), but every other streamFn in the same file does and is already warn-free. Matches the existing disable-comment style in this repo (// eslint-disable-next-line <rule> with no reason trailer).

  • query-core/__tests__/streamedQuery.test.tsx:553, 715

Out of scope

28 additional require-await warnings remain in packages/query-codemods/src/*/__testfixtures__/ — those files are codemod input/output fixtures that intentionally mirror user code shapes and must not be modified.

✅ 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 test mocking patterns across multiple packages to use explicit Promise-returning functions instead of async/throw patterns for consistency.
    • Added ESLint suppressions for async generator functions without await expressions.
    • Refactored async test function signatures to remove unnecessary async/await where not needed.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 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: d5bfe421-d201-4908-8cad-7029be599469

📥 Commits

Reviewing files that changed from the base of the PR and between cf8a765 and 7a2fa29.

📒 Files selected for processing (4)
  • packages/query-core/src/__tests__/queryObserver.test.tsx
  • packages/query-core/src/__tests__/streamedQuery.test.tsx
  • packages/react-query/src/__tests__/useQuery.test.tsx
  • packages/solid-query/src/__tests__/useQuery.test.tsx

📝 Walkthrough

Walkthrough

Test-only modifications across multiple packages to adjust how mock queryFn implementations handle Promise returns. Changes replace async function syntax with explicit Promise.resolve() and Promise.reject() calls, remove unnecessary async declarations from test functions, and add ESLint suppressions for async generators.

Changes

Cohort / File(s) Summary
Promise handling in mock queryFn
packages/query-core/src/__tests__/queryObserver.test.tsx, packages/react-query/src/__tests__/useQuery.test.tsx, packages/solid-query/src/__tests__/useQuery.test.tsx
Modified queryFn implementations from async functions with implicit returns/throws to non-async functions explicitly returning Promise.resolve() or Promise.reject(), preserving async semantics while changing function form.
Test function async declaration cleanup
packages/solid-query/src/__tests__/useQuery.test.tsx
Removed async keyword from test function signatures in three test cases (enabled=false initial state, query hash function tests) that perform immediate synchronous assertions.
ESLint suppressions
packages/query-core/src/__tests__/streamedQuery.test.tsx
Added inline eslint-disable-next-line @typescript-eslint/require-await`` comments above async generator function definitions that lack await expressions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Promises unwrapped, no async await,
Mock functions now explicit—their fate's not opaque!
Test declarations simplified, ESLint suppressed,
The test suite hops forward, thoroughly blessed! 🌟

🚥 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
Title check ✅ Passed The title accurately summarizes the main change: resolving ESLint 'require-await' warnings across test files, which is clearly reflected in the changeset.
Description check ✅ Passed The description thoroughly covers all required sections: Changes (with detailed strategy breakdown), Checklist (all items completed), and Release Impact (correctly marked as docs/CI/dev-only).
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.

✏️ 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/fix-require-await-warnings

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 21, 2026

View your CI Pipeline Execution ↗ for commit 7a2fa29

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

☁️ Nx Cloud last updated this comment at 2026-04-21 18:09:15 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 21, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 7a2fa29

@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 merged commit 59efc40 into main Apr 21, 2026
10 checks passed
@sukvvon sukvvon deleted the test/fix-require-await-warnings branch April 21, 2026 22:50
Ephem pushed a commit to Ephem/react-query that referenced this pull request Apr 23, 2026
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