Skip to content

test(query-core): replace deprecated 'toBeCalledWith' and 'toBeCalledTimes' with 'toHaveBeenCalledWith' and 'toHaveBeenCalledTimes'#10967

Merged
sukvvon merged 1 commit into
mainfrom
test/query-core-replace-deprecated-tobecalled
Jun 17, 2026
Merged

test(query-core): replace deprecated 'toBeCalledWith' and 'toBeCalledTimes' with 'toHaveBeenCalledWith' and 'toHaveBeenCalledTimes'#10967
sukvvon merged 1 commit into
mainfrom
test/query-core-replace-deprecated-tobecalled

Conversation

@sukvvon

@sukvvon sukvvon commented Jun 17, 2026

Copy link
Copy Markdown
Member

🎯 Changes

toBeCalledWith and toBeCalledTimes are deprecated Jest-style aliases in Vitest. This replaces the remaining usages in query-core tests with their canonical toHaveBeenCalledWith / toHaveBeenCalledTimes forms, matching the rest of the suite.

  • infiniteQueryObserver.test.tsx: toBeCalledWithtoHaveBeenCalledWith, toBeCalledTimestoHaveBeenCalledTimes
  • queriesObserver.test.tsx: toBeCalledTimestoHaveBeenCalledTimes
  • mutationObserver.test.tsx: toBeCalledTimestoHaveBeenCalledTimes
  • query.test.tsx: toBeCalledWithtoHaveBeenCalledWith

Purely a matcher-name change; no assertion behavior is altered.

✅ 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 test files for improved assertion validation and consistency.

…Times' with 'toHaveBeenCalledWith' and 'toHaveBeenCalledTimes'
@coderabbitai

coderabbitai Bot commented Jun 17, 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: c382c32a-e17b-44f7-a72d-e69d355cb741

📥 Commits

Reviewing files that changed from the base of the PR and between 18d4504 and 6dbeeeb.

📒 Files selected for processing (4)
  • packages/query-core/src/__tests__/infiniteQueryObserver.test.tsx
  • packages/query-core/src/__tests__/mutationObserver.test.tsx
  • packages/query-core/src/__tests__/queriesObserver.test.tsx
  • packages/query-core/src/__tests__/query.test.tsx

📝 Walkthrough

Walkthrough

Four test files in packages/query-core/src/__tests__/ replace deprecated Vitest matcher aliases (toBeCalledWith, toBeCalledTimes) with their canonical equivalents (toHaveBeenCalledWith, toHaveBeenCalledTimes). No test logic, assertions values, or production code is changed.

Changes

Vitest Matcher Alias Replacement

Layer / File(s) Summary
Matcher alias updates across test files
packages/query-core/src/__tests__/query.test.tsx, packages/query-core/src/__tests__/infiniteQueryObserver.test.tsx, packages/query-core/src/__tests__/mutationObserver.test.tsx, packages/query-core/src/__tests__/queriesObserver.test.tsx
Replaces toBeCalledWith/toBeCalledTimes with toHaveBeenCalledWith/toHaveBeenCalledTimes in assertions for queryFn call signatures, meta propagation, and subscription handler call counts.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • TanStack/query#10935: Same pattern of replacing deprecated Vitest matcher aliases with canonical equivalents in test assertions.
  • TanStack/query#10937: Directly aligned changes replacing toBeCalledTimes/toBeCalledWith with toHaveBeenCalledTimes/toHaveBeenCalledWith across test files.
  • TanStack/query#10939: Updates the same class of Vitest matcher assertions for queryFn/subscription/meta call-count expectations.

Poem

🐇 Hop hop, the matchers align,
toHaveBeenCalled — so divine!
No more aliases, old and stale,
The canonical path shall prevail.
The tests still pass, the bunny cheers,
Refactored joy through all the tiers! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the primary change: replacing deprecated Vitest matcher aliases with their canonical forms across multiple test files.
Description check ✅ Passed The description follows the template with a clear 'Changes' section detailing the specific replacements, a completed checklist, and accurate release impact assessment.
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/query-core-replace-deprecated-tobecalled

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

@nx-cloud

nx-cloud Bot commented Jun 17, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 6dbeeeb

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

☁️ Nx Cloud last updated this comment at 2026-06-17 10:50:33 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.

@sukvvon sukvvon self-assigned this Jun 17, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 17, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 6dbeeeb

@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 0bed37a into main Jun 17, 2026
9 checks passed
@sukvvon sukvvon deleted the test/query-core-replace-deprecated-tobecalled branch June 17, 2026 10:52
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