Skip to content

test(svelte-query-devtools): add tests for missing 'QueryClient', context provider, and 'client' prop#10625

Merged
sukvvon merged 1 commit intomainfrom
test/svelte-query-devtools-add-client-and-context-tests
May 3, 2026
Merged

test(svelte-query-devtools): add tests for missing 'QueryClient', context provider, and 'client' prop#10625
sukvvon merged 1 commit intomainfrom
test/svelte-query-devtools-add-client-and-context-tests

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 3, 2026

🎯 Changes

Add wrapper invariant tests for SvelteQueryDevtools, following up on #10624.

  • Add should throw an error if no query client has been set.
  • Add should not throw an error if query client is provided via context (using a new Wrapper.svelte helper that renders SvelteQueryDevtools inside <QueryClientProvider>).
  • Add should not throw an error if query client is provided via props.

This brings svelte-query-devtools in line with solid-query-devtools, which already covers the same three cases.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:lib (4/4 passed).

🚀 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
    • Enhanced test coverage for devtools to validate proper QueryClient configuration. Added test cases ensuring devtools correctly handles scenarios where QueryClient is missing, provided via context, or passed as a prop, with appropriate error handling validation.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec35cfb4-c6c1-407a-b164-541bfabc2a2c

📥 Commits

Reviewing files that changed from the base of the PR and between 529e590 and 8d8c4e0.

📒 Files selected for processing (2)
  • packages/svelte-query-devtools/tests/Devtools.svelte.test.ts
  • packages/svelte-query-devtools/tests/Wrapper.svelte

📝 Walkthrough

Walkthrough

Added test coverage for SvelteQueryDevtools error handling when a QueryClient is missing or provided. Introduced a Wrapper.svelte test helper component that provides QueryClient via Svelte context, and extended the test suite with three new assertions.

Changes

Test Coverage & Infrastructure

Layer / File(s) Summary
Test Helper Component
packages/svelte-query-devtools/tests/Wrapper.svelte
New typed component that accepts queryClient via $props() and wraps SvelteQueryDevtools within QueryClientProvider for context-based testing.
Test Cases
packages/svelte-query-devtools/tests/Devtools.svelte.test.ts
Three new test assertions: (1) rendering without QueryClient throws expected error, (2) rendering via Wrapper with context-provided client succeeds, (3) rendering with client prop directly succeeds.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes


🐰 Devtools now test their safety net,
With context and props, no client? You bet!
A Wrapper so fine, a helper so true,
Errors caught early—what more can we do?

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change—adding tests for QueryClient handling in three scenarios.
Description check ✅ Passed The description follows the template with complete sections: detailed changes explaining the three test cases, a checked checklist confirming contribution guide compliance and local testing, and release impact marked as dev-only.
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.

✏️ 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-devtools-add-client-and-context-tests

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 3, 2026

View your CI Pipeline Execution ↗ for commit 8d8c4e0

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

☁️ Nx Cloud last updated this comment at 2026-05-03 01:51:37 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 3, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 8d8c4e0

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

size-limit report 📦

Path Size
react full 12.1 KB (0%)
react minimal 9.07 KB (0%)

@sukvvon sukvvon self-assigned this May 3, 2026
@sukvvon sukvvon merged commit 3f0948b into main May 3, 2026
10 checks passed
@sukvvon sukvvon deleted the test/svelte-query-devtools-add-client-and-context-tests branch May 3, 2026 01:58
Sign up for free to 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