-
Notifications
You must be signed in to change notification settings - Fork 664
Add comprehensive unit tests for NpmRegistryClient with http mocking #5568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TheLarkInn
merged 2 commits into
atomic-style-claude
from
copilot/sub-pr-5565-another-one
Jan 25, 2026
Merged
Add comprehensive unit tests for NpmRegistryClient with http mocking #5568
TheLarkInn
merged 2 commits into
atomic-style-claude
from
copilot/sub-pr-5565-another-one
Jan 25, 2026
+426
−4
Conversation
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
…ent with http mocking Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] WIP to address feedback on package-json and throat dependency replacements
Add comprehensive unit tests for NpmRegistryClient with http mocking
Jan 25, 2026
TheLarkInn
approved these changes
Jan 25, 2026
TheLarkInn
added a commit
that referenced
this pull request
Jan 27, 2026
…5568) * Initial plan * test(npm-check-fork): add comprehensive unit tests for NpmRegistryClient with http mocking Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com>
TheLarkInn
added a commit
that referenced
this pull request
Jan 27, 2026
* feat(npm-check-fork): add npm registry type definitions Add INpmRegistryPackageResponse and INpmRegistryVersionMetadata interfaces to support the upcoming replacement of the package-json dependency with a local implementation using WebClient. - INpmRegistryVersionMetadata extends INpmCheckPackageVersion for backward compatibility - INpmRegistryPackageResponse models the full npm registry API response - Added JSDoc with links to npm registry API documentation * feat(npm-check-fork): add NpmRegistryClient for fetching package metadata Implement NpmRegistryClient class to replace external package-json dependency with a self-contained HTTP client using Node.js built-in modules. Features: - INpmRegistryClientOptions for configuring registry URL, user agent, timeout - INpmRegistryClientResult for consistent error handling - Automatic scoped package URL encoding (@scope/name -> @scope%2Fname) - Support for gzip/deflate response decompression - Proper error handling for 404, HTTP errors, network errors, and timeouts * refactor(npm-check-fork): use NpmRegistryClient in GetLatestFromRegistry Replace package-json and throat dependencies with NpmRegistryClient for fetching npm registry metadata. Preserves existing version sorting and homepage extraction logic. Changes: - Remove package-json and throat imports - Add lazy-initialized module-level NpmRegistryClient instance - Update getNpmInfo to use fetchPackageMetadataAsync - Preserve lodash/semver version sorting - Preserve bestGuessHomepage extraction * feat(npm-check-fork): add getNpmInfoBatch for concurrent package fetching Add batch fetching function to retrieve metadata for multiple packages concurrently with configurable concurrency limit. Features: - getNpmInfoBatch(packageNames, concurrency) returns Map<string, INpmRegistryInfo> - Default concurrency matches CPU count (like original throat behavior) - Processes packages in batches using Promise.all * refactor(npm-check-fork): remove package-json and throat dependencies Remove external dependencies that have been replaced by NpmRegistryClient: - package-json: replaced by NpmRegistryClient - throat: replaced by Promise.all batch processing Update tests to mock NpmRegistryClient instead of package-json. * test(npm-check-fork): add unit tests for NpmRegistryClient Add basic unit tests for NpmRegistryClient constructor options. Update GetLatestFromRegistry tests with improved module mocking. * docs(npm-check-fork): update CHANGELOG for dependency replacement Document the removal of package-json and throat dependencies in favor of internal NpmRegistryClient implementation. * cleanup from code review * remove ai outputs * rush change * restore CHANGELOG.md * docs(npm-check-fork): fix JSDoc claiming interface extends when it doesn't (#5567) * Initial plan * docs: reword JSDoc for structural compatibility instead of extends Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> * Add comprehensive unit tests for NpmRegistryClient with http mocking (#5568) * Initial plan * test(npm-check-fork): add comprehensive unit tests for NpmRegistryClient with http mocking Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> * DROP: rush update --------- Co-authored-by: Sean Larkin <thelarkinn@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com>
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.
Addresses code review feedback requesting test coverage for the custom HTTP client implementation introduced in the package-json and throat dependency replacement.
Changes
Test Coverage: Added 17 unit tests mocking
http.request/https.requestto validate:@scope/name→@scope%2Fname)Implementation
Tests use Jest mocks and EventEmitter to simulate HTTP request/response lifecycle without network calls:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.