Skip to content

test: add coverage for critical resolveDependencyTree#1911

Merged
danielroe merged 1 commit intomainfrom
serhalp/test-resolveDependencyTree
Mar 4, 2026
Merged

test: add coverage for critical resolveDependencyTree#1911
danielroe merged 1 commit intomainfrom
serhalp/test-resolveDependencyTree

Conversation

@serhalp
Copy link
Member

@serhalp serhalp commented Mar 4, 2026

🔗 Linked issue

N/A

🧭 Context

I reviewed the latest coverage report and identified resolveDependencyTree as a critical piece of complex untested business logic.

📚 Description

Add tests for resolveDependencyTree

@vercel
Copy link

vercel bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 4, 2026 1:48am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 4, 2026 1:48am
npmx-lunaria Ignored Ignored Mar 4, 2026 1:48am

Request Review

@serhalp serhalp force-pushed the serhalp/test-resolveDependencyTree branch from 41aa588 to a51b125 Compare March 4, 2026 01:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

A new resolveDependencyTree method has been added to the server utilities dependency-resolver module and exported as part of the public API. Comprehensive unit tests were introduced to cover the method's functionality across multiple scenarios, including single packages, direct and transitive dependencies, optional dependencies, platform filtering, version-range handling, circular dependencies, and dependency deduplication. Test utilities were added to support the testing effort, with 264 lines added and 3 lines removed overall.

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description directly addresses the changeset, explaining the motivation (coverage report identifying untested logic) and the action taken (adding tests for resolveDependencyTree).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch serhalp/test-resolveDependencyTree

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 036dfc2 and a51b125.

📒 Files selected for processing (1)
  • test/unit/server/utils/dependency-resolver.spec.ts

Comment on lines +320 to +329
it('continues resolving when fetchPackument fails for a dependency', async () => {
mockFetchNpmPackage.mockImplementation(async (name: string) => {
if (name === 'root')
return makePackument('root', [
{ version: '1.0.0', deps: { broken: '^1.0.0', healthy: '^1.0.0' } },
])
if (name === 'broken') return null
if (name === 'healthy') return makePackument('healthy', [{ version: '1.0.0' }])
return null
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Model fetch failures with rejected promises, not null values.

Line 326 currently returns null for broken, but production failure is a thrown error handled in fetchPackument’s catch. This test therefore misses the real failure-handling path it describes.

Suggested tweak
-        if (name === 'broken') return null
+        if (name === 'broken')
+          throw new Error('mock registry failure')

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@danielroe danielroe added this pull request to the merge queue Mar 4, 2026
Merged via the queue into main with commit 94f95fa Mar 4, 2026
23 checks passed
@danielroe danielroe deleted the serhalp/test-resolveDependencyTree branch March 4, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants