test(solid-query-persist-client/PersistQueryClientProvider): replace 'toMatchObject' with 'toEqual'#11044
Conversation
…'toMatchObject' with 'toEqual'
|
View your CI Pipeline Execution ↗ for commit c57138a
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
📝 WalkthroughWalkthroughUpdated five ChangesPersisted query state tests
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
size-limit report 📦
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx`:
- Around line 117-129: Replace `toEqual` with `toStrictEqual` in all five
pending-state shape assertions in `PersistQueryClientProvider.test.tsx`,
ensuring each check verifies that the `data: undefined` property is explicitly
present.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: abaa75d5-4b9e-4e66-b6b1-d30f3f91a0f6
📒 Files selected for processing (1)
packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx
| expect(states[0]).toEqual({ | ||
| status: 'pending', | ||
| fetchStatus: 'idle', | ||
| data: undefined, | ||
| }) | ||
|
|
||
| expect(states[1]).toMatchObject({ | ||
| expect(states[1]).toEqual({ | ||
| status: 'success', | ||
| fetchStatus: 'fetching', | ||
| data: 'hydrated', | ||
| }) | ||
|
|
||
| expect(states[2]).toMatchObject({ | ||
| expect(states[2]).toEqual({ |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
fd -a -t f '^(package\.json|pnpm-lock\.yaml|yarn\.lock|package-lock\.json|bun\.lock)$' \
| xargs -r rg -n '"vitest"'
rg -n 'expect\(states\[[0-9]+\]\)\.to(Equal|StrictEqual)\(' \
packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsxRepository: TanStack/query
Length of output: 2631
🏁 Script executed:
#!/bin/bash
set -eu
sed -n '90,145p' packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx
printf '\n----\n'
sed -n '180,225p' packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx
printf '\n----\n'
sed -n '270,310p' packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx
printf '\n----\n'
sed -n '360,390p' packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx
printf '\n----\n'
sed -n '575,605p' packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsxRepository: TanStack/query
Length of output: 4946
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
p = Path('packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx')
text = p.read_text()
for i, line in enumerate(text.splitlines(), 1):
if 'toEqual({' in line or 'toStrictEqual({' in line or 'data: undefined' in line:
if 100 <= i <= 610:
print(f'{i}: {line}')
PYRepository: TanStack/query
Length of output: 782
Use toStrictEqual for the pending-state shape checks. toEqual treats a missing data key the same as data: undefined, so these assertions can miss a regression where the pending state stops including the property. Replace it in all five blocks.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx`
around lines 117 - 129, Replace `toEqual` with `toStrictEqual` in all five
pending-state shape assertions in `PersistQueryClientProvider.test.tsx`,
ensuring each check verifies that the `data: undefined` property is explicitly
present.
🎯 Changes
The
statesarray in these tests is populated with hand-built literals of exactly three fields (status,fetchStatus,data) — its type isArray<{ status; fetchStatus; data }>. Since every field is asserted and no extra fields exist, the partialtoMatchObjectmatcher is tightened to the exacttoEqual, which additionally catches any unexpected extra key on the observed state.Note: the sibling react-query persist test pushes the raw
UseQueryResult(dozens of fields), sotoMatchObjectis correct there and is left unchanged — only this solid test builds a 3-field literal.✅ Checklist
🚀 Release Impact
Summary by CodeRabbit