Skip to content

test(svelte-query/queryOptions): add runtime test for identity function#10178

Open
sukvvon wants to merge 7 commits intoTanStack:mainfrom
sukvvon:test/svelte-query-queryOptions-runtime
Open

test(svelte-query/queryOptions): add runtime test for identity function#10178
sukvvon wants to merge 7 commits intoTanStack:mainfrom
sukvvon:test/svelte-query-queryOptions-runtime

Conversation

@sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Feb 24, 2026

🎯 Changes

Add a runtime test for queryOptions identity function in @tanstack/svelte-query, matching the existing test in @tanstack/react-query.

✅ 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
    • Added a unit test verifying that the query options helper returns inputs unchanged, improving reliability and confidence in option handling. No public APIs were modified. This is a test-only, low-risk change with minimal review effort.

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2026

⚠️ No Changeset found

Latest commit: d749e83

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39b15be and fc06f53.

📒 Files selected for processing (1)
  • packages/svelte-query/tests/queryOptions/queryOptions.svelte.test.ts

📝 Walkthrough

Walkthrough

Adds a Vitest unit test that asserts queryOptions(obj) returns the exact same object (strict equality) for an object with queryKey and queryFn.

Changes

Cohort / File(s) Summary
Query Options Test
packages/svelte-query/tests/queryOptions/queryOptions.svelte.test.ts
Adds a Vitest test asserting queryOptions(obj) returns the identical input object (uses strict equality toBe).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested reviewers

  • TkDodo

Poem

🐰 A tiny test hopped into my paws,
I checked an object without a pause,
It stayed the same — no shuffle, no gloss,
Quietly true, I nibbled a boss,
Carrots crunch, hooray for small laws. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a runtime test for the queryOptions identity function in svelte-query.
Description check ✅ Passed The description follows the template structure with all required sections completed: Changes section explains the addition, Checklist items are marked appropriately, and Release Impact is properly assessed as dev-only.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@nx-cloud
Copy link

nx-cloud bot commented Feb 24, 2026

View your CI Pipeline Execution ↗ for commit fc06f53

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

☁️ Nx Cloud last updated this comment at 2026-02-26 14:48:30 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 24, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: fc06f53

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/svelte-query/tests/queryOptions/queryOptions.svelte.test.ts (1)

1-5: The .svelte.test.ts extension doesn't match the test's contents.

This test is a pure unit test with no Svelte-specific code (no flushSync, $state, component mounting, etc.). While the entire svelte-query test suite consistently uses .svelte.test.ts for uniformity, this file could be renamed to .test.ts for accuracy, since other files in the package that actually use Svelte runtime features share the same extension. Consider renaming to .test.ts unless there's a specific reason to maintain the package-wide .svelte.test.ts convention.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/svelte-query/tests/queryOptions/queryOptions.svelte.test.ts` around
lines 1 - 5, The test file uses only plain unit tests for the exported function
queryOptions and therefore should be renamed from queryOptions.svelte.test.ts to
queryOptions.test.ts to reflect that it contains no Svelte-specific code; locate
the test that imports queryOptions (symbol: queryOptions) and rename the file
extension, and if any project scripts or test-indexing rely on the
.svelte.test.ts convention update them accordingly so the test runner still
discovers the renamed file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/svelte-query/tests/queryOptions/queryOptions.svelte.test.ts`:
- Line 11: The test currently asserts structural equality but should assert
reference identity; update the assertion in the test for queryOptions to use
toBe instead of toStrictEqual so it verifies that queryOptions(object) returns
the exact same object reference (i.e.,
expect(queryOptions(object)).toBe(object)); locate the assertion referencing
queryOptions in the queryOptions.svelte.test.ts and replace the matcher
accordingly.

---

Nitpick comments:
In `@packages/svelte-query/tests/queryOptions/queryOptions.svelte.test.ts`:
- Around line 1-5: The test file uses only plain unit tests for the exported
function queryOptions and therefore should be renamed from
queryOptions.svelte.test.ts to queryOptions.test.ts to reflect that it contains
no Svelte-specific code; locate the test that imports queryOptions (symbol:
queryOptions) and rename the file extension, and if any project scripts or
test-indexing rely on the .svelte.test.ts convention update them accordingly so
the test runner still discovers the renamed file.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb7dca5 and 47746e6.

📒 Files selected for processing (1)
  • packages/svelte-query/tests/queryOptions/queryOptions.svelte.test.ts

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