Skip to content

Comments

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

Open
sukvvon wants to merge 1 commit intoTanStack:mainfrom
sukvvon:test/svelte-query-queryOptions-runtime
Open

test(svelte-query/queryOptions): add runtime test for identity function#10178
sukvvon wants to merge 1 commit 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 test coverage for queryOptions functionality to verify expected behavior.

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2026

⚠️ No Changeset found

Latest commit: 47746e6

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

📝 Walkthrough

Walkthrough

A new test file was added to verify that the queryOptions function returns the input object unchanged. The test imports necessary Vitest utilities and the queryOptions function, then validates strict equality between input and output.

Changes

Cohort / File(s) Summary
Query Options Test
packages/svelte-query/tests/queryOptions/queryOptions.svelte.test.ts
New test verifying that queryOptions(obj) returns the exact same object without modification, with assertion on strict equality.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A test was born, so small and neat,
queryOptions shines, no tricks to cheat,
Same input, same output—what a treat!
Strict equality makes the logic sweet,
Our tests are growing, victory's complete! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a runtime test for the queryOptions identity function in svelte-query, which matches the changeset content.
Description check ✅ Passed The description follows the template structure with all required sections completed: Changes explained, all checklist items addressed, and Release Impact clearly marked 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 docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 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 47746e6

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

☁️ Nx Cloud last updated this comment at 2026-02-24 02:38:24 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: 47746e6

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

queryFn: () => Promise.resolve(5),
} as const

expect(queryOptions(object)).toStrictEqual(object)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use toBe instead of toStrictEqual to assert reference identity.

The PR explicitly targets testing the identity function contract — that queryOptions returns the exact same object reference passed in. queryOptions "just returns whatever you pass into it" at runtime, so the test should verify reference equality (===), not structural equality.

toStrictEqual performs a deep value comparison. It would pass even if queryOptions returned a new object with the same shape (same queryFn reference and equal queryKey elements), silently allowing a regression if the implementation ever copies the input instead of returning it directly.

🐛 Proposed fix
-    expect(queryOptions(object)).toStrictEqual(object)
+    expect(queryOptions(object)).toBe(object)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(queryOptions(object)).toStrictEqual(object)
expect(queryOptions(object)).toBe(object)
🤖 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` at 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.

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