Skip to content

test(lit-query): create 'queryClient' in 'beforeEach' and drop unneeded 'retry: false' default options - #11677

Merged
sukvvon merged 1 commit into
mainfrom
test/lit-query-query-client-before-each
Sep 26, 2026
Merged

sukvvon merged 1 commit into
mainfrom
test/lit-query-query-client-before-each

Conversation

@sukvvon

@sukvvon sukvvon commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

Aligns the lit-query tests' QueryClient setup with the other adapters' tests (e.g. react-query):

  • Declares let queryClient: QueryClient in the top-level describes, creates it in beforeEach (after vi.useFakeTimers()) and calls queryClient.clear() in afterEach (before vi.useRealTimers()). type-inference.test.ts does the same without fake timers, and client-switch-controllers.test.ts keeps creating its two clients in each test because every test there switches between them.
  • Tests that created a single local client now use the shared queryClient. Tests that need several clients (switching between providers, or an explicit client compared with a provider client) still create the extra clients inline.
  • Drops defaultOptions: { queries: { retry: false } } (and mutations: { retry: false }) from the clients. Only two tests have a failing query, so they now set retry: false on that query instead.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 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 Lit Query test setup to reuse a fresh query client for each test and clear it afterward.
    • Tests now use default retry behavior in most scenarios, while retaining explicit retry settings where needed.
    • Existing controller, provider, cache, and type-inference coverage remains in place.

@sukvvon sukvvon self-assigned this Sep 26, 2026
@nx-cloud

nx-cloud Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 3bb4d49

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

☁️ Nx Cloud last updated this comment at 2026-09-26 17:55:28 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.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7f5142df-b80b-4b05-9667-025fb0583697

📥 Commits

Reviewing files that changed from the base of the PR and between 0c40a4b and 3bb4d49.

📒 Files selected for processing (9)
  • packages/lit-query/src/tests/base-controller.test.ts
  • packages/lit-query/src/tests/client-switch-controllers.test.ts
  • packages/lit-query/src/tests/context-provider.test.ts
  • packages/lit-query/src/tests/counters-and-state.test.ts
  • packages/lit-query/src/tests/infinite-and-options.test.ts
  • packages/lit-query/src/tests/mutation-controller.test.ts
  • packages/lit-query/src/tests/queries-controller.test.ts
  • packages/lit-query/src/tests/query-controller.test.ts
  • packages/lit-query/src/tests/type-inference.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The Lit query test suites now create and clear shared QueryClient instances for each test. Many tests remove client-level retry overrides, while selected failing-query cases retain retry settings in their query options.

Changes

Lit query test updates

Layer / File(s) Summary
Shared setup in provider and type tests
packages/lit-query/src/tests/base-controller.test.ts, packages/lit-query/src/tests/context-provider.test.ts, packages/lit-query/src/tests/type-inference.test.ts
Provider and type-inference tests use a per-test QueryClient and clear it during teardown.
Query controller tests
packages/lit-query/src/tests/client-switch-controllers.test.ts, packages/lit-query/src/tests/queries-controller.test.ts, packages/lit-query/src/tests/query-controller.test.ts
Query and multi-query controller tests reuse shared clients for controller setup, provider changes, cache assertions, and lifecycle cases. Client-switch tests use default client options.
Mutation controllers and state helpers
packages/lit-query/src/tests/counters-and-state.test.ts, packages/lit-query/src/tests/mutation-controller.test.ts
Mutation-controller and counter/state tests reuse shared clients for mutation operations, helper calls, cache checks, and provider cases.
Infinite-query and options tests
packages/lit-query/src/tests/infinite-and-options.test.ts
Infinite-query and options tests reuse a per-test client. The next-page failure case retains retry: false in its query options.

Priority: ⬇️ Low

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

Change: Other

Merge Risk: ⚪ Minimal · up to 3bb4d

The Lit query test setup changes do not establish a production behavior change or a test regression. The PR is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 9…
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.
Title check ✅ Passed The title clearly and concisely summarizes the two main changes: shared QueryClient setup in beforeEach and removal of unnecessary retry defaults.
Description check ✅ Passed The description includes all required template sections, explains the changes and motivation, completes the checklist, and correctly identifies the change as dev-only with no release impact.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@pkg-pr-new

pkg-pr-new Bot commented Sep 26, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 3bb4d49

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.73 KB (0%)
react minimal 8.58 KB (0%)

@sukvvon
sukvvon merged commit 66a7103 into main Sep 26, 2026
9 checks passed
@sukvvon
sukvvon deleted the test/lit-query-query-client-before-each branch September 26, 2026 18:20
Sign up for free to 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.

1 participant