Skip to content

test(lit-query): replace inline 'new Promise' timeouts with 'sleep' from 'query-test-utils' - #11104

Merged
sukvvon merged 5 commits into
mainfrom
test/lit-query-sleep-helper
Aug 20, 2026
Merged

test(lit-query): replace inline 'new Promise' timeouts with 'sleep' from 'query-test-utils'#11104
sukvvon merged 5 commits into
mainfrom
test/lit-query-sleep-helper

Conversation

@sukvvon

@sukvvonsukvvon commented Jul 22, 2026

Copy link
Copy Markdown
Member

🎯 Changes

lit-query's tests were the only ones in the repo still writing new Promise((resolve) => setTimeout(resolve, N)) inline instead of using the shared sleep(N) helper from @tanstack/query-test-utils that every other adapter package's tests already use. Added @tanstack/query-test-utils as a devDependency and replaced all 14 occurrences across client-switch-controllers.test.ts, counters-and-state.test.ts, mutation-controller.test.ts, and query-controller.test.ts. No behavior change — sleep is implemented identically to the inlined promise.

Left untouched: promises that resolve manually via a captured resolve reference (e.g. resolveRefetch, resolveOld, resolveFetch), since those aren't fixed-delay timeouts.

✅ 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 the reliability and consistency of timing-based automated tests.
    • Standardized asynchronous wait handling across query and mutation scenarios.
    • Enhanced coverage of state transitions, callback ordering, and controller behavior.
  • Chores
    • Consolidated test timing utilities to support more predictable test execution.
    • No user-facing functionality or public API changes were introduced.

@coderabbitai

coderabbitaiBot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: de184062-a15f-4795-b9d9-e52b723123fc

📥 Commits

Reviewing files that changed from the base of the PR and between 64a8035 and 2857017.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • packages/lit-query/package.json
  • packages/lit-query/src/tests/client-switch-controllers.test.ts
  • packages/lit-query/src/tests/counters-and-state.test.ts
  • packages/lit-query/src/tests/mutation-controller.test.ts
  • packages/lit-query/src/tests/query-controller.test.ts
  • packages/lit-query/src/tests/testHost.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/lit-query/package.json
  • packages/lit-query/src/tests/testHost.ts
  • packages/lit-query/src/tests/mutation-controller.test.ts
  • packages/lit-query/src/tests/client-switch-controllers.test.ts
  • packages/lit-query/src/tests/counters-and-state.test.ts
  • packages/lit-query/src/tests/query-controller.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The Lit Query package adds @tanstack/query-test-utils as a development dependency and replaces inline setTimeout-based test delays with the shared sleep helper across controller tests and test helpers.

Changes

Lit Query test timing utility adoption

Layer / File(s)Summary
Shared sleep utility adoption
packages/lit-query/package.json, packages/lit-query/src/tests/client-switch-controllers.test.ts, packages/lit-query/src/tests/counters-and-state.test.ts, packages/lit-query/src/tests/mutation-controller.test.ts, packages/lit-query/src/tests/testHost.ts
Adds the test utility dependency and replaces inline timer Promises with sleep in controller tests and the waitFor helper.
Query controller sleep migration
packages/lit-query/src/tests/query-controller.test.ts
Replaces inline timer Promises with sleep across transition, cancellation, lifecycle, retry, provider, zero-delay, and hydration tests.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk:⚪ Minimal · up to 28570

This change standardizes fixed-delay test code without changing published behavior; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

Suggested reviewers:tkdodo

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
Title check✅ PassedThe title clearly and concisely describes replacing inline timeout promises with the shared sleep helper in lit-query tests.
Description check✅ PassedThe description explains the changes and motivation, completes both checklist items, and identifies the change as dev-only with no release impact.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/lit-query-sleep-helper

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sukvvonsukvvon self-assigned this Jul 22, 2026
@nx-cloud

nx-cloudBot commented Jul 22, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 2857017

CommandStatusDurationResult
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded7m 46sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded2sView ↗

☁️ Nx Cloud last updated this comment at 2026-08-20 00:44:07 UTC

@github-actions

github-actionsBot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

9 package(s) bumped directly, 16 bumped as dependents.

🟨 Minor bumps

PackageVersionReason
@tanstack/angular-query-experimental5.101.4 → 5.102.0Changeset
@tanstack/eslint-plugin-query5.101.4 → 5.102.0Changeset
@tanstack/preact-query5.101.4 → 5.102.0Changeset
@tanstack/query-core5.101.4 → 5.102.0Changeset
@tanstack/react-query5.101.4 → 5.102.0Changeset
@tanstack/solid-query5.101.4 → 5.102.0Changeset
@tanstack/vue-query5.101.4 → 5.102.0Changeset
@tanstack/angular-query-persist-client5.101.4 → 5.102.0Dependent
@tanstack/preact-query-devtools5.101.4 → 5.102.0Dependent
@tanstack/preact-query-persist-client5.101.4 → 5.102.0Dependent
@tanstack/query-async-storage-persister5.101.4 → 5.102.0Dependent
@tanstack/query-broadcast-client-experimental5.101.4 → 5.102.0Dependent
@tanstack/query-devtools5.101.4 → 5.102.0Dependent
@tanstack/query-persist-client-core5.101.4 → 5.102.0Dependent
@tanstack/query-sync-storage-persister5.101.4 → 5.102.0Dependent
@tanstack/react-query-devtools5.101.4 → 5.102.0Dependent
@tanstack/react-query-next-experimental5.101.4 → 5.102.0Dependent
@tanstack/react-query-persist-client5.101.4 → 5.102.0Dependent
@tanstack/solid-query-devtools5.101.4 → 5.102.0Dependent
@tanstack/solid-query-persist-client5.101.4 → 5.102.0Dependent

🟩 Patch bumps

PackageVersionReason
@tanstack/lit-query0.2.11 → 0.2.12Changeset
@tanstack/svelte-query6.1.38 → 6.1.39Changeset
@tanstack/svelte-query-devtools6.1.38 → 6.1.39Dependent
@tanstack/svelte-query-persist-client6.1.38 → 6.1.39Dependent
@tanstack/vue-query-devtools6.1.38 → 6.1.39Dependent

@pkg-pr-new

pkg-pr-newBot commented Jul 22, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11104

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 2857017

@github-actions

github-actionsBot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
react full12.26 KB (0%)
react minimal9.21 KB (0%)

@sukvvon
sukvvon marked this pull request as draft July 22, 2026 07:52
@TkDodo

Copy link
Copy Markdown
Collaborator

@sukvvon there’s something not quite right here, errors are persistent. do you want to get this over the finish line or should we close it?

@sukvvon

sukvvon commented Aug 19, 2026

Copy link
Copy Markdown
MemberAuthor

@TkDodo Let's finish it. lit-query is the only package on moduleResolution: NodeNext, tripping TS2835 on query-test-utils's imports. Once #10943 merges and drops that override, this is fixed — verified locally.

@sukvvon
sukvvon requested a review from TkDodoAugust 19, 2026 01:10
@sukvvon
sukvvon marked this pull request as ready for review August 20, 2026 00:35
@coderabbitai

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@sukvvon
sukvvon merged commit 5e1b866 into mainAug 20, 2026
9 checks passed
@sukvvon
sukvvon deleted the test/lit-query-sleep-helper branch August 20, 2026 00:44
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@sukvvon@TkDodo