test(vue-query/{usePrefetchQuery,usePrefetchInfiniteQuery}): assert exact prefetch options instead of 'objectContaining'#11056
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit c08c5fa
☁️ Nx Cloud last updated this comment at |
Contributor
📝 WalkthroughWalkthroughThe Vue prefetch query and infinite-query tests now use stable query functions and assert exact prefetch options, including unwrapped reactive keys, pagination callbacks, and ordered calls after reactive key changes. ChangesVue prefetch test assertions
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Contributor
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
Contributor
size-limit report 📦
|
…xact prefetch options instead of 'objectContaining'
c08c5fa to
dd5a785
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
The
usePrefetchQuery/usePrefetchInfiniteQuerytests spy onqueryClient.prefetchQuery/prefetchInfiniteQueryand check the forwarded options. They matched onlyqueryKeyviaexpect.objectContaining(...), leaving the rest of the forwarded options (queryFn,initialPageParam,getNextPageParam) unverified. SincecloneDeepUnrefpreserves function references, the full options object can be asserted exactly.objectContaining({ queryKey })→ exact object — asserts the whole forwarded options, so extra/missing keys are caught.expect.any(Function)→ reference — inlinequeryFn/getNextPageParamare extracted to consts and asserted by reference, so the test verifies the exact function is forwarded, not just "some function". A sibling test already used this reference-matching style.toHaveBeenLastCalledWith→toHaveBeenNthCalledWith(n, ...)in the reactive-key-change tests, pinning each call to its position (first call = old key, second = new key). The redundanttoHaveBeenCalledTimes(1)before the firstNth(1)is dropped, while thetoHaveBeenCalledTimes(2)guarding the total call count is kept.queryFnunwrapped fromvi.fn(...)to a plain function — these tests never use its mock features, so the wrapper was noise;getNextPageParamwas already plain.✅ Checklist
🚀 Release Impact
Summary by CodeRabbit