Skip to content

test({react,preact,angular}-query/{queryOptions,infiniteQueryOptions,mutationOptions}): replace 'toStrictEqual' with 'toBe' and add type annotations#10192

Merged
TkDodo merged 1 commit intoTanStack:mainfrom
sukvvon:test/options-toBe-and-add-types
Feb 26, 2026

Conversation

@sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Feb 26, 2026

🎯 Changes

  • Replace toStrictEqual with toBe for identity function assertions in queryOptions, infiniteQueryOptions, and mutationOptions tests across react-query, preact-query, and angular-query-experimental
  • Add explicit type annotations (UseMutationOptions / CreateMutationOptions) to mutationOptions test objects for consistency with queryOptions and infiniteQueryOptions tests

Since these options functions are identity functions that return the same reference, toBe (reference equality) is more precise than toStrictEqual (deep equality). This aligns with the change made in #10135 for solid-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
    • Updated test assertions across multiple packages to verify that option functions return consistent object references
    • Added explicit type annotations to test objects for enhanced type safety validation

…mutationOptions}): replace 'toStrictEqual' with 'toBe' for identity function assertion and add explicit type annotations to 'mutationOptions'
@changeset-bot
Copy link

changeset-bot bot commented Feb 26, 2026

⚠️ No Changeset found

Latest commit: c6acd98

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 26, 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 978fc52 and c6acd98.

📒 Files selected for processing (9)
  • packages/angular-query-experimental/src/__tests__/infinite-query-options.test.ts
  • packages/angular-query-experimental/src/__tests__/mutation-options.test.ts
  • packages/angular-query-experimental/src/__tests__/query-options.test.ts
  • packages/preact-query/src/__tests__/infiniteQueryOptions.test.tsx
  • packages/preact-query/src/__tests__/mutationOptions.test.tsx
  • packages/preact-query/src/__tests__/queryOptions.test.tsx
  • packages/react-query/src/__tests__/infiniteQueryOptions.test.tsx
  • packages/react-query/src/__tests__/mutationOptions.test.tsx
  • packages/react-query/src/__tests__/queryOptions.test.tsx

📝 Walkthrough

Walkthrough

This PR updates test assertions across multiple packages to validate object reference identity instead of deep structural equality, and adds explicit type annotations to test objects in mutation option tests.

Changes

Cohort / File(s) Summary
Query Options Tests
packages/angular-query-experimental/src/__tests__/query-options.test.ts, packages/preact-query/src/__tests__/queryOptions.test.tsx, packages/react-query/src/__tests__/queryOptions.test.tsx
Assertion method changed from toStrictEqual to toBe, requiring queryOptions to return the exact same object reference rather than a structurally equivalent copy.
Infinite Query Options Tests
packages/angular-query-experimental/src/__tests__/infinite-query-options.test.ts, packages/preact-query/src/__tests__/infiniteQueryOptions.test.tsx, packages/react-query/src/__tests__/infiniteQueryOptions.test.tsx
Assertion method changed from toStrictEqual to toBe to validate strict reference identity of returned objects.
Mutation Options Tests
packages/angular-query-experimental/src/__tests__/mutation-options.test.ts, packages/preact-query/src/__tests__/mutationOptions.test.tsx, packages/react-query/src/__tests__/mutationOptions.test.tsx
Type imports added (UseMutationOptions / CreateMutationOptions), test objects explicitly typed, and assertions changed from toStrictEqual to toBe for reference equality validation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

package: react-query, package: angular-query-experimental, package: preact-query

Suggested reviewers

  • TkDodo
  • arnoud-dv
  • manudeli

Poem

🐰 With whiskers twitching, tests now check,
Not what's inside, but what's the ref!
From deep equality to identity true,
Same object back—we verify you!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: replacing toStrictEqual with toBe and adding type annotations across multiple query option test files.
Description check ✅ Passed The description follows the template structure with complete sections explaining changes, rationale, and release impact. All required checklist items are addressed.
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 26, 2026

View your CI Pipeline Execution ↗ for commit c6acd98

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

☁️ Nx Cloud last updated this comment at 2026-02-26 12:52:57 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 26, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: c6acd98

@TkDodo TkDodo merged commit 74276f0 into TanStack:main Feb 26, 2026
7 checks passed
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.

2 participants