test(fetch-client): restore globalThis.fetch in afterEach#2668
Conversation
Save original fetch before mocking and restore it after each test to prevent cross-test pollution. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR improves test isolation in the fetch-client test suite by properly preserving and restoring the original ChangesFetch Mock Test Isolation
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)
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 |
|
Claude finished @ymc9's task —— View job ✅ PR Review CompleteTodo List:
SummaryThis is a clean and well-executed fix for preventing test pollution in the fetch-client test suite. Code Quality & Best Practices ✅
Potential Bugs/Issues ✅
Performance Considerations ✅
Security Concerns ✅
Test Coverage Impact ✅
Specific Code Reviewpackages/clients/fetch-client/test/fetch-client.test.ts:21 const originalFetch = globalThis.fetch;✅ Good: Captured at the right scope (describe block) to be available for cleanup packages/clients/fetch-client/test/fetch-client.test.ts:29 globalThis.fetch = originalFetch;✅ Good: Properly restores the original fetch in afterEach, ensuring test isolation RecommendationApproved - This is a textbook example of proper test cleanup. The changes are minimal, focused, and solve a real problem with test isolation. No changes needed. |
Summary
globalThis.fetchat describe scope and restore it inafterEachso the mocked fetch does not leak into other test files.Test plan
pnpm vitest run test/fetch-client.test.tsinpackages/clients/fetch-clientpasses (47/47).🤖 Generated with Claude Code
Summary by CodeRabbit