test(vue-query/useMutation): replace 'vi.waitFor' with 'vi.advanceTimersByTimeAsync' in async 'mutateAsync' tests#10966
Conversation
…ersByTimeAsync' in async 'mutateAsync' tests
|
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 (1)
📝 WalkthroughWalkthroughTwo ChangesuseMutation async test timer handling
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 9087067
☁️ 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. |
size-limit report 📦
|
🎯 Changes
The
asyncblock inuseMutation.test.tswas the only place still usingvi.waitForto awaitmutateAsync, even though the suite runs under fake timers and every other test drives time withvi.advanceTimersByTimeAsync. This replaces it so the async tests follow the same explicit fake-timer pattern as the rest of the file.should resolve properly: hold themutateAsyncpromise, advance the timer, thenawait expect(promise).resolves.toBe(result).should throw on error:await Promise.all([expect(mutation.mutateAsync()).rejects.toThrow('Some error'), vi.advanceTimersByTimeAsync(10)]). The rejection assertion is attached before the timer is advanced (the reject fires inside theadvanceTimersByTimeAsynccall), so the rejection is handled at the moment it occurs — avoiding an unhandled rejection while still satisfyingvitest/valid-expect.No behavior change to the assertions themselves; the subsequent
toMatchObjectstate checks are unchanged.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Release Notes
No user-facing changes. This release includes internal test infrastructure improvements to ensure more reliable test execution.