Skip to content

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

Open
sukvvon wants to merge 6 commits into
mainfrom
test/query-core-replace-deprecated-vitest-aliases
Open

test(query-core): replace deprecated 'toBeCalledWith' and 'toBeCalledTimes' with 'toHaveBeenCalledWith' and 'toHaveBeenCalledTimes'#10936
sukvvon wants to merge 6 commits into
mainfrom
test/query-core-replace-deprecated-vitest-aliases

Conversation

@sukvvon

@sukvvon sukvvon commented Jun 14, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Replace the deprecated assertion aliases toBeCalledWith and toBeCalledTimes with their recommended counterparts toHaveBeenCalledWith and toHaveBeenCalledTimes across the query-core test suite.

Both aliases are flagged @deprecated by @vitest/expect's type definitions, which point to the replacements used here:

  • toBeCalledWithtoHaveBeenCalledWith
  • toBeCalledTimestoHaveBeenCalledTimes

Affected files:

  • query.test.tsx
  • queriesObserver.test.tsx
  • infiniteQueryObserver.test.tsx
  • mutationObserver.test.tsx

✅ 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

Release Notes

  • Tests
    • Updated test assertion patterns across the test suite to align with current testing framework standards.
    • Verified behavior validation for observer subscriptions, query function invocations, and mutation handling continues as expected.
    • Improves consistency and maintainability of test code across all test files.

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

coderabbitai Bot commented Jun 14, 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: 5615aa4b-dafb-43a1-96a9-743cafbae076

📥 Commits

Reviewing files that changed from the base of the PR and between 43a4ea0 and 1fd6328.

📒 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__/ are updated to replace deprecated toBeCalledWith and toBeCalledTimes matcher aliases with the canonical toHaveBeenCalledWith and toHaveBeenCalledTimes forms. No test logic, expected values, or public APIs are changed.

Changes

Vitest Matcher Standardization

Layer / File(s) Summary
Replace toBeCalled* with toHaveBeenCalled*
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
Five assertions in infiniteQueryObserver.test.tsx, four in mutationObserver.test.tsx, two in queriesObserver.test.tsx, and one in query.test.tsx are updated to use the canonical Vitest matcher names. Expected values and test logic are unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • TanStack/query#10935: Applies the same toBeCalledWith/toBeCalledTimestoHaveBeenCalledWith/toHaveBeenCalledTimes rename to a different set of observer/query test files in the same package.

Poem

🐇 Hop, hop, the matchers align,
toHaveBeenCalled — now that's divine!
No more aliases lurking about,
The canonical name leaves no doubt.
A tidy warren, tests in a row,
Watch those assertions put on a show! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: replacing deprecated test assertion matchers with their recommended counterparts.
Description check ✅ Passed The description follows the template structure, clearly explains the changes and their motivation, includes the affected files, and completes all required checklist items appropriately.
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-vitest-aliases

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

@nx-cloud

nx-cloud Bot commented Jun 14, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 47b6fc8

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ❌ Failed 2m 8s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 11s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-14 12:33:15 UTC

@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 14, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 47b6fc8

@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.11 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon sukvvon self-assigned this Jun 14, 2026
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