Skip to content

test(solid-query): add 'renderWithClient' helper and replace inline 'QueryClientProvider' wrapping in tests#10950

Merged
sukvvon merged 1 commit into
mainfrom
test/solid-query-render-with-client-helper
Jun 14, 2026
Merged

test(solid-query): add 'renderWithClient' helper and replace inline 'QueryClientProvider' wrapping in tests#10950
sukvvon merged 1 commit into
mainfrom
test/solid-query-render-with-client-helper

Conversation

@sukvvon

@sukvvon sukvvon commented Jun 14, 2026

Copy link
Copy Markdown
Member

🎯 Changes

The solid-query tests wrapped almost every render in an inline QueryClientProvider:

const rendered = render(() => (
  <QueryClientProvider client={queryClient}>
    <Page />
  </QueryClientProvider>
))

react-query and preact-query already share a renderWithClient helper in their test utils.tsx for exactly this; this adds the equivalent to solid-query and uses it across the test suite.

  • Add renderWithClient(client, ui) to src/__tests__/utils.tsx. It mirrors the react/preact helper but takes a () => JSX.Element (matching solid's render), and returns the underlying render result unchanged (solid tests don't use rerender, so no wrapping is needed).
  • Replace the inline QueryClientProvider wrapping with renderWithClient(...) across the test files, and drop the now-unused QueryClientProvider / render imports.
  • QueryClientProvider.test.tsx is intentionally left untouched — it tests the provider itself (including multiple/nested providers and the missing-provider throw case).

No test behavior changes: the whole solid-query suite (21 files, 320 tests) passes with no type errors. Net ~880 fewer lines of boilerplate.

✅ 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

  • Chores
    • Improved internal test infrastructure and maintainability through refactored test utilities for the solid-query test suite.

@coderabbitai

coderabbitai Bot commented Jun 14, 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: 3660209c-55c4-47a6-86d2-153379c94ba9

📥 Commits

Reviewing files that changed from the base of the PR and between 6048592 and efb08aa.

📒 Files selected for processing (11)
  • packages/solid-query/src/__tests__/mutationOptions.test.tsx
  • packages/solid-query/src/__tests__/suspense.test.tsx
  • packages/solid-query/src/__tests__/transition.test.tsx
  • packages/solid-query/src/__tests__/useInfiniteQuery.test.tsx
  • packages/solid-query/src/__tests__/useIsFetching.test.tsx
  • packages/solid-query/src/__tests__/useIsMutating.test.tsx
  • packages/solid-query/src/__tests__/useMutation.test.tsx
  • packages/solid-query/src/__tests__/useMutationState.test.tsx
  • packages/solid-query/src/__tests__/useQueries.test.tsx
  • packages/solid-query/src/__tests__/useQuery.test.tsx
  • packages/solid-query/src/__tests__/utils.tsx

📝 Walkthrough

Walkthrough

Introduces a renderWithClient(client, ui) helper in packages/solid-query/src/__tests__/utils.tsx that wraps a Solid component with QueryClientProvider. All ten solid-query test files then replace their per-test render(() => <QueryClientProvider client={queryClient}>...</QueryClientProvider>) pattern with calls to this helper.

Changes

renderWithClient helper and adoption

Layer / File(s) Summary
renderWithClient helper definition
packages/solid-query/src/__tests__/utils.tsx
Exports renderWithClient(client, ui) which renders the given element wrapped in QueryClientProvider; adds required imports for render, QueryClientProvider, and Solid/Vitest types.
Adopt helper across all test files
packages/solid-query/src/__tests__/mutationOptions.test.tsx, suspense.test.tsx, transition.test.tsx, useInfiniteQuery.test.tsx, useIsFetching.test.tsx, useIsMutating.test.tsx, useMutation.test.tsx, useMutationState.test.tsx, useQueries.test.tsx, useQuery.test.tsx
Removes QueryClientProvider from imports across all ten test files and replaces every render(() => <QueryClientProvider client={queryClient}>...</QueryClientProvider>) callsite with renderWithClient(queryClient, () => <Component />). In useMutation.test.tsx and suspense.test.tsx, ErrorBoundary and Blink wrappers are repositioned inside the renderWithClient callback rather than outside the provider.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TanStack/query#10916: Also modifies useIsFetching.test.tsx to change how QueryClient is provided in hook tests, using a centralized beforeEach/afterEach setup instead of the renderWithClient approach introduced here.
  • TanStack/query#10917: Also modifies mutationOptions.test.tsx to centralize queryClient creation/usage across test cases, directly overlapping with this PR's changes to that file.
  • TanStack/query#10919: Also refactors useIsMutating.test.tsx to restructure QueryClient creation and spied-client usage, intersecting with the useIsMutating changes in this PR.

Poem

🐰 Hoppity hop, the boilerplate's gone,
A helper now wraps every dawn.
No more providers typed by hand,
renderWithClient rules the land!
One small util, ten files made clean —
The tidiest test suite you've ever seen. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a renderWithClient helper and replacing inline QueryClientProvider wrapping across the solid-query test suite.
Description check ✅ Passed The description covers the changes, motivation, testing checklist completion, and release impact status, following the template structure with substantive content.
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.

✏️ 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/solid-query-render-with-client-helper

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

@sukvvon sukvvon self-assigned this Jun 14, 2026
@nx-cloud

nx-cloud Bot commented Jun 14, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit efb08aa

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

☁️ Nx Cloud last updated this comment at 2026-06-14 17:58:24 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.

@pkg-pr-new

pkg-pr-new Bot commented Jun 14, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: efb08aa

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

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

@sukvvon sukvvon merged commit 0e2bfe7 into main Jun 14, 2026
9 checks passed
@sukvvon sukvvon deleted the test/solid-query-render-with-client-helper branch June 14, 2026 18:13
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