test: add comprehensive tests for resolve-target module#199
Merged
Conversation
Add unit tests for org/project resolution functions: - resolveOrg: CLI flags, defaults, DSN detection fallback - resolveFromDsn: cache hits, API fetches, missing orgId/projectId - resolveOrgAndProject: flag validation, defaults, DSN, directory inference - resolveAllTargets: monorepo multi-DSN, deduplication, error propagation Coverage improved from 15.28% to 95.65% (366 → ~30 uncovered lines).
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Dsn
Other
Bug Fixes 🐛
Documentation 📚
Internal Changes 🔧
Other
🤖 This preview updates automatically when you update the PR. |
- Move integration tests with mock.module() to test/isolated/ directory to run separately from unit tests (Bun mocks affect global module state) - Keep pure function property tests in test/lib/resolve-target.test.ts - Add test:isolated script for running isolated tests - Coverage improved from 15.28% to 72.49% for resolve-target.ts The isolated tests cover: - resolveOrg: CLI flags, defaults, DSN detection, error handling - resolveFromDsn: cache hits, API fetches, fallback behavior - resolveOrgAndProject: flag validation, defaults, DSN, directory inference - resolveAllTargets: monorepo multi-DSN, deduplication, empty results
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 1709 uncovered lines. Files with missing lines (32)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 77.35% 77.20% -0.15%
==========================================
Files 55 57 +2
Lines 7394 7497 +103
Branches 0 0 —
==========================================
+ Hits 5719 5788 +69
- Misses 1675 1709 +34
- Partials 0 0 —Generated by Codecov Action |
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
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.
Summary
resolve-target.tsChanges
Test Structure
Due to Bun's
mock.module()affecting global module state, tests are organized into:test/lib/resolve-target.test.ts- Pure function property tests (no mocks)isValidDirNameForInferenceproperty and edge case tests (7 tests)test/isolated/resolve-target.test.ts- Integration tests with mocked dependencies (27 tests)bun run test:isolatedto avoid interfering with other testsFunctions Tested
isValidDirNameForInferenceresolveOrgresolveFromDsnresolveOrgAndProjectresolveAllTargetsPackage.json
Added new test script:
Running Tests