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 into
mainfrom
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 into
mainfrom
test/svelte-query-createQueries-fake-timers

Conversation

@sukvvon

@sukvvonsukvvon commented Apr 5, 2026

Copy link
Copy Markdown
Member

🎯 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

coderabbitaiBot commented Apr 5, 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: 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 nameStatusExplanation
Title check✅ PassedThe title accurately and specifically describes the main changes: switching to fake timers, replacing vi.waitFor calls, and moving queryClient to beforeEach hook.
Description check✅ PassedThe description follows the template structure with detailed changes, completed checklist items, and clear release impact assessment.
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/svelte-query-createQueries-fake-timers

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

@nx-cloud

nx-cloudBot commented Apr 5, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit ddeef27

CommandStatusDurationResult
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded57sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded<1sView ↗

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

@sukvvonsukvvon self-assigned this Apr 5, 2026
@github-actions

github-actionsBot commented Apr 5, 2026

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

pkg-pr-newBot commented Apr 5, 2026

Copy link
Copy Markdown
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

size-limit report 📦

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

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