Skip to content

[Issue]: Refactor Package-Extension.ps1 entry point for testability #263

@WilliamBerryiii

Description

@WilliamBerryiii

Issue Description

scripts/extension/Package-Extension.ps1 has a 129-line <script> entry point block that cannot be tested via dot-sourcing. This code handles path validation, version resolution, directory operations, vsce invocation, and cleanup.

Current state:

  • File coverage: 27% line (55/204)
  • Method coverage: 100% (7/7) — all pure functions are tested
  • Entry point: 0% coverage (129 lines)

Acceptance criteria:

  • Extract entry point logic into Invoke-PackageExtension function
  • Keep <script> block as thin wrapper calling the new function
  • Add comprehensive tests with mocked file system and vsce calls
  • Test parameter validation, error paths, and cleanup logic
  • Achieve ≥85% line coverage

Estimated coverage improvement: 27% → ~90%

Additional Context

This follows the refactoring pattern established in PR #221 ("extract pure functions for Pester testability"). The entry point contains business logic that should be testable:

  • Version resolution from manifest
  • Extension directory validation
  • vsce command construction
  • Output path handling

This is part of a broader effort to increase unit test coverage from ~42% to ~85-90%.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttestingTest infrastructure and test files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions