mirror of
https://github.com/Comfy-Org/Comfy-PR.git
synced 2026-11-04 23:37:33 +00:00
[PR #90] [MERGED] feat: add MSW for mocking GitHub API in tests #91
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/Comfy-PR#91
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/Comfy-PR/pull/90
Author: @snomiao
Created: 10/22/2025
Status: ✅ Merged
Merged: 10/25/2025
Merged by: @snomiao
Base:
main← Head:sno-external-service-mocking📝 Commits (3)
2a361c4feat: add MSW for mocking GitHub API in testsc52c56cMerge branch 'main' into sno-external-service-mocking078b998fix: improve type safety and clean up test code📊 Changes
9 files changed (+1806 additions, -82 deletions)
View changed files
📝
.env.test(+1 -1)📝
bun.lock(+99 -2)📝
bunfig.toml(+1 -1)📝
package.json(+1 -0)➖
src/check/security-scan.spec.ts(+0 -78)➕
src/gh.spec.ts(+564 -0)➕
src/test/README.md(+296 -0)➕
src/test/github-handlers.ts(+816 -0)➕
src/test/msw-setup.ts(+28 -0)📄 Description
Summary
This PR sets up Mock Service Worker (MSW) for comprehensive GitHub API mocking in tests, providing a more realistic and maintainable alternative to manual
jest.mockpatterns.What's New
🧪 Testing Infrastructure
src/gh.spec.tswith 35 tests (all passing)📚 Documentation
🎯 Coverage
All GitHub API endpoints used in Comfy-PR:
Repos API (8 endpoints)
Pulls API (6 endpoints)
Issues API (9 endpoints)
Git API (2 endpoints)
Users API (2 endpoints)
Benefits
✅ More Realistic: Mocks actual HTTP requests, not module implementations
✅ Type Safe: Full TypeScript support with Octokit types
✅ Centralized: Single source of truth for mock data
✅ Maintainable: Easy to add/update endpoints
✅ Transparent: Existing tests continue to work without changes
Test Results
All tests cover:
Migration Path
Existing tests using
jest.mock("@/src/gh")can:Files Changed
src/test/msw-setup.ts- MSW server lifecyclesrc/test/github-handlers.ts- All GitHub API mock handlerssrc/test/README.md- Documentationsrc/gh.spec.ts- Test suitebunfig.toml- Test configurationpackage.json- Added msw@^2.11.6Next Steps
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.