Skip to content

test(svelte-query/createQueries): switch to fake timers, replace 'vi.waitFor' with 'vi.advanceTimersByTimeAsync', and move 'queryClient' to 'beforeEach'#10388

Merged
sukvvon merged 2 commits intomainfrom
test/svelte-query-createQueries-fake-timers
Apr 5, 2026
Merged

test(svelte-query/createQueries): switch to fake timers, replace 'vi.waitFor' with 'vi.advanceTimersByTimeAsync', and move 'queryClient' to 'beforeEach'#10388
sukvvon merged 2 commits intomainfrom
test/svelte-query-createQueries-fake-timers

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 5, 2026

🎯 Changes

  • Add vi.useFakeTimers() to beforeEach and vi.useRealTimers() to afterEach
  • Move queryClient creation from describe-level const to beforeEach for per-test isolation
  • Replace all vi.waitFor with vi.advanceTimersByTimeAsync(0) for deterministic timer control
  • Remove redundant vi.useFakeTimers() / vi.useRealTimers() from individual isRestoring tests

✅ 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 infrastructure and timing mechanisms for better test reliability and consistency.

Note: This release contains internal testing improvements only. No user-facing features, bug fixes, or API changes included.

…waitFor' with 'vi.advanceTimersByTimeAsync', and move 'queryClient' to 'beforeEach'
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 5, 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: 3ece5c49-a969-4804-b0a5-dfeb11dcdb28

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2cd73 and ddeef27.

📒 Files selected for processing (1)
  • packages/svelte-query/tests/createQueries/createQueries.svelte.test.ts

📝 Walkthrough

Walkthrough

Test setup refactored in createQueries.svelte.test.ts to consolidate fake timer and QueryClient lifecycle management via beforeEach/afterEach hooks, while replacing synchronous vi.waitFor() polling-based assertions with vi.advanceTimersByTimeAsync(0) timer-flush patterns.

Changes

Cohort / File(s) Summary
Test Lifecycle & Timer Refactoring
packages/svelte-query/tests/createQueries/createQueries.svelte.test.ts
Centralized fake timer initialization (vi.useFakeTimers()) and QueryClient creation/cleanup in beforeEach/afterEach hooks; replaced vi.waitFor() polling assertions with vi.advanceTimersByTimeAsync(0) for deterministic timer flushing; removed redundant per-test timer setup code.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 Timers tick in harmony,
No more polling, wild and free,
Setup once, then flush away,
Tests now swift, hooray, hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main changes: switching to fake timers, replacing vi.waitFor calls, and moving queryClient to beforeEach hook.
Description check ✅ Passed The description follows the template structure with detailed changes, completed checklist items, and clear release impact assessment.
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/svelte-query-createQueries-fake-timers

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 5, 2026

View your CI Pipeline Execution ↗ for commit ddeef27

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

☁️ Nx Cloud last updated this comment at 2026-04-05 07:50:47 UTC

@sukvvon sukvvon self-assigned this Apr 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 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 5, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: ddeef27

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

size-limit report 📦

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

@sukvvon sukvvon merged commit 7781a3e into main Apr 5, 2026
8 checks passed
@sukvvon sukvvon deleted the test/svelte-query-createQueries-fake-timers branch April 5, 2026 07:55
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