test: add coverage for critical resolveDependencyTree#1911
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
41aa588 to
a51b125
Compare
📝 WalkthroughWalkthroughA new 🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 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 |
| 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 | ||
| }) |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🔗 Linked issue
N/A
🧭 Context
I reviewed the latest coverage report and identified
resolveDependencyTreeas a critical piece of complex untested business logic.📚 Description
Add tests for
resolveDependencyTree