Skip to content

test(solid-query-devtools): extract shared test setup into 'beforeEach'#11028

Merged
sukvvon merged 1 commit into
mainfrom
test/solid-query-devtools-shared-setup
Jul 4, 2026
Merged

test(solid-query-devtools): extract shared test setup into 'beforeEach'#11028
sukvvon merged 1 commit into
mainfrom
test/solid-query-devtools-shared-setup

Conversation

@sukvvon

@sukvvon sukvvon commented Jul 4, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Removes the const queryClient = new QueryClient() repeated in every test of SolidQueryDevtools and SolidQueryDevtoolsPanel by hoisting it into a beforeEach, exposed via a let binding.

The per-test vi.spyOn(TanstackQueryDevtools.prototype, ...) calls are left as-is: each test spies only the setter it asserts on, so they are intentionally not shared.

No test behavior changes; all existing assertions are preserved.

✅ 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
    • Simplified and standardized the devtools test setup.
    • Improved test cleanup and consistency while keeping existing behavior checks unchanged.

@nx-cloud

nx-cloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 221c01b

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

☁️ Nx Cloud last updated this comment at 2026-07-04 06:21:18 UTC

@coderabbitai

coderabbitai Bot commented Jul 4, 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

Run ID: 27d4b4fa-0096-4b03-9246-0b41960c2f58

📥 Commits

Reviewing files that changed from the base of the PR and between be8f11b and 221c01b.

📒 Files selected for processing (2)
  • packages/solid-query-devtools/src/__tests__/devtools.test.tsx
  • packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx

📝 Walkthrough

Walkthrough

Test suites in devtools.test.tsx and devtoolsPanel.test.tsx were refactored to initialize a shared QueryClient instance within a beforeEach hook, replacing repeated per-test new QueryClient() declarations. No assertions or exported/public entity declarations changed.

Changes

Shared QueryClient Test Refactor

Layer / File(s) Summary
devtools.test.tsx shared setup
packages/solid-query-devtools/src/__tests__/devtools.test.tsx
Adds beforeEach import and a shared queryClient variable initialized before each test, with all test cases updated to reference it instead of creating local instances.
devtoolsPanel.test.tsx shared setup
packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx
Adds a shared queryClient variable initialized in beforeEach and cleaned up via vi.restoreAllMocks() in afterEach, with all test cases updated to use it instead of local instances.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • TanStack/query#10917: Same code-level pattern of centralizing QueryClient creation into a shared beforeEach across a test suite.
  • TanStack/query#10918: Refactors another test suite to use a shared let queryClient initialized in beforeEach/afterEach, replacing per-test instantiations.
  • TanStack/query#10919: Centralizes QueryClient setup with shared beforeEach/afterEach, mirroring the same refactor pattern.

Poem

A rabbit hopped through tests anew,
No more new QueryClient() in every stew,
One shared client, tidy and neat,
beforeEach makes the suite complete,
Hop, hop, refactor done — hooray for you! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: extracting shared test setup into beforeEach for solid-query-devtools tests.
Description check ✅ Passed The description follows the required template and includes changes, checklist, and release impact with the needed details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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/solid-query-devtools-shared-setup

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

@github-actions

github-actions Bot commented Jul 4, 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-new Bot commented Jul 4, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 221c01b

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.13 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon sukvvon merged commit 27e680f into main Jul 4, 2026
9 checks passed
@sukvvon sukvvon deleted the test/solid-query-devtools-shared-setup branch July 4, 2026 06:33
@sukvvon sukvvon self-assigned this Jul 4, 2026
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