test(solid-query): assert exact values instead of loose matchers#11105
Open
reizam wants to merge 1 commit into
Open
test(solid-query): assert exact values instead of loose matchers#11105reizam wants to merge 1 commit into
reizam wants to merge 1 commit into
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughTests tighten Solid Query cache and mutation assertions by validating stored data values, cache isolation, explicit ChangesSolid Query test assertions
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Continues the recent test-quality series (e.g. #11057, #11093) by converting the
toBeTruthy()/toBeFalsy()/toBeDefined()assertions insolid-querytests to exact assertions:QueryClientProvider— cache presence checks now assert the exact cached value (?.state.data) produced by the test'squeryFn, and the cross-cache absence checks in the partitioning test usetoBeUndefined()instead ofnot.toBeDefined(). One redundant existence check was removed where the next line already asserts?.options.gcTimeon the same query (it fails onundefinedeither way).suspense— the cache absence check before mount usestoBeUndefined()instead oftoBeFalsy().useQuery— after the first fetch in the client-switch test, the presence check onqueryClient1's cache now asserts the exact cached value.mutationOptions— removedexpect(lastSnapshot[1]).toBeFalsy(): the precedingexpect(lastSnapshot.length).toEqual(1)already guarantees there is no second entry.One
toBeDefined()is intentionally left in place: inuseQuery→ "should refetch query when queryClient changes", tightening thequeryClient2cache check to?.state.datafails. AftersetClient(queryClient2), the secondqueryFncall actually lands inqueryClient1's cache (itsdataUpdateCountgoes to 2) while the entry inqueryClient2's cache staysstatus: 'pending'/fetchStatus: 'idle'and never fetches. This looks like an observer re-subscription ordering issue inuseBaseQuery(in theon(client, ...)computed,createClientSubscriber()is called beforesetObserver(newObserver), so the subscription attaches to the old observer). I'd rather report and fix that separately than encode the current behavior into an exact assertion here.After this,
grep -rE 'toBeTruthy\(\)|toBeFalsy\(\)|toBeDefined\(\)' packages/solid-query/srconly matches the site described above.✅ Checklist
Local verification detail:
vitest runon the four edited files — 162 tests passed, no type errors;test:eslintand prettier clean; full-suite failure set identical tomainin the same environment.🚀 Release Impact
Summary by CodeRabbit