test({vue,angular}-query): pin the reactive refetch call with 'toHaveBeenNthCalledWith'#11051
Merged
Conversation
Contributor
📝 WalkthroughWalkthroughChangesQuery call assertions
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 69cb67b
☁️ Nx Cloud last updated this comment at |
Contributor
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
Contributor
size-limit report 📦
|
…BeenNthCalledWith'
65936f1 to
69cb67b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
These tests change a reactive query key and refetch, so
queryFn/fetchFnfires twice — first with the old key, then with the new key. The calls were asserted with order-agnostictoHaveBeenCalledWith, 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/useQuery—keyRefchanged thenrefetch(); both calls pinned by orderangular-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
Summary by CodeRabbit