Skip to content

test({vue,angular}-query): pin the reactive refetch call with 'toHaveBeenNthCalledWith'#11051

Merged
sukvvon merged 2 commits into
mainfrom
test/reactive-refetch-nth
Jul 12, 2026
Merged

test({vue,angular}-query): pin the reactive refetch call with 'toHaveBeenNthCalledWith'#11051
sukvvon merged 2 commits into
mainfrom
test/reactive-refetch-nth

Conversation

@sukvvon

@sukvvon sukvvon commented Jul 11, 2026

Copy link
Copy Markdown
Member

🎯 Changes

These tests change a reactive query key and refetch, so queryFn/fetchFn fires twice — first with the old key, then with the new key. The calls were asserted with order-agnostic toHaveBeenCalledWith, which passes as long as some call carried a given key, regardless of order. That leaves the sequence unverified: an assertion for the new key could be satisfied by the wrong call.

Switching to toHaveBeenNthCalledWith(n, ...) pins each assertion to a specific call, so the first call is verified to use the old key and the second (the refetch after the key changed) is verified to use the new key.

  • vue-query/useQuerykeyRef changed then refetch(); both calls pinned by order
  • angular-query-experimental/inject-query — key signal changed then re-run; both the refetch case and the options-signal-change case pinned by order (the inline comment already states the intent is "the new queryKey")

✅ Checklist

🚀 Release Impact

  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Improved accuracy for query refetching tests after reactive query key updates.
    • Tests now assert the exact `fetchFn`/`queryFn` arguments by invocation order (first vs. second call), ensuring the correct query key is used on each refetch.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Query call assertions

Layer / File(s) Summary
Invocation-specific verification
packages/angular-query-experimental/src/__tests__/inject-query.test.ts, packages/vue-query/src/__tests__/useQuery.test.ts
Tests now use toHaveBeenNthCalledWith to verify initial and updated queryKey arguments on the expected query or fetch invocations.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly states the test change and the use of toHaveBeenNthCalledWith, matching the PR’s main intent.
Description check ✅ Passed The description follows the template with Changes, Checklist, and Release Impact sections and is sufficiently filled out.
✨ 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/reactive-refetch-nth

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

@nx-cloud

nx-cloud Bot commented Jul 11, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 69cb67b

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

☁️ Nx Cloud last updated this comment at 2026-07-12 03:06: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 Jul 11, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 11, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: fc33e19

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

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

@sukvvon sukvvon force-pushed the test/reactive-refetch-nth branch from 65936f1 to 69cb67b Compare July 12, 2026 02:57
@sukvvon sukvvon merged commit aa1f9d7 into main Jul 12, 2026
9 checks passed
@sukvvon sukvvon deleted the test/reactive-refetch-nth branch July 12, 2026 03:09
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