Skip to content

test(query-core): replace 'vi.waitFor' with 'vi.advanceTimersByTimeAsync' in 'query.test.tsx'#10434

Merged
sukvvon merged 1 commit intomainfrom
test/query-core-query-replace-waitFor-with-advanceTimersByTimeAsync
Apr 9, 2026
Merged

test(query-core): replace 'vi.waitFor' with 'vi.advanceTimersByTimeAsync' in 'query.test.tsx'#10434
sukvvon merged 1 commit intomainfrom
test/query-core-query-replace-waitFor-with-advanceTimersByTimeAsync

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 9, 2026

🎯 Changes

✅ 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
    • Improved test timing reliability for query-related test cases.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 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: 70bd3213-f0c1-4f72-bf04-1fbdfe3b02f1

📥 Commits

Reviewing files that changed from the base of the PR and between ef62f7b and 73016d0.

📒 Files selected for processing (1)
  • packages/query-core/src/__tests__/query.test.tsx

📝 Walkthrough

Walkthrough

Test timing control is refactored to use fake-timer advancement (advanceTimersByTimeAsync) instead of polling via waitFor in query core tests. Two tests are modified: one simplifies timer advancement after starting a fetch operation, and another replaces async waiting for idle status with direct timer advancement followed by synchronous assertion.

Changes

Cohort / File(s) Summary
Test Timing Control
packages/query-core/src/__tests__/query.test.tsx
Replaced vi.waitFor polling with advanceTimersByTimeAsync for timer-based async flow control in two tests, removing intermediate timer advances and using synchronous assertions after explicit timer progression.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

package: query-core

Poem

🐰 Timer ticks, no more waiting around,
Fake clocks spin to test's steady ground,
Assertions now march with precision and grace,
Each millisecond in its proper place! ⏰

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: replacing vi.waitFor calls with vi.advanceTimersByTimeAsync in query.test.tsx.
Description check ✅ Passed The description includes all required sections from the template (Changes, Checklist, Release Impact) with appropriate details about the specific modifications and their scope.
Docstring Coverage ✅ Passed No 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-query-replace-waitFor-with-advanceTimersByTimeAsync

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

@sukvvon sukvvon self-assigned this Apr 9, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 9, 2026

View your CI Pipeline Execution ↗ for commit 73016d0

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

☁️ Nx Cloud last updated this comment at 2026-04-09 00:38:54 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

🚀 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 9, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 73016d0

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

size-limit report 📦

Path Size
react full 11.98 KB (0%)
react minimal 9.01 KB (0%)

@sukvvon sukvvon merged commit 6b95cd8 into main Apr 9, 2026
10 checks passed
@sukvvon sukvvon deleted the test/query-core-query-replace-waitFor-with-advanceTimersByTimeAsync branch April 9, 2026 00:41
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