PowerShell / PowerShellEditorServices

A common platform for PowerShell development support in any editor or application!
MIT License
622 stars 213 forks source link

Support Run/Debug tests in PSKoans-files #1988

Closed fflaten closed 1 year ago

fflaten commented 1 year ago

PR Summary

Adds support for using Run/Debug Tests codelens and Run/Debug Pester Tests commands with *.Koans.ps1-files used by PSKoans.

Manually testing only for InvokePesterStub.ps1 to avoid extra dependency for a simple feature.

PR Context

Fix PowerShell/vscode-powershell#4363

fflaten commented 1 year ago

Be aware that if a different Pester-version than the one used by PSKoans (currently 4.10.1) is already loaded, run/debug tests will fail during import. The same error occurs in a normal PowerShell-session, but mentioning it since we may get feedback here.

Importing PSKoans module...
Exception: /workspaces/vscode-powershell/modules/PowerShellEditorServices/InvokePesterStub.ps1:70:9
Line |
  70 |          $psKoansModule = Microsoft.PowerShell.Core\Import-Module PSKo …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Assertion operator name 'Be' has been added multiple times.
WARNING: Failed to import PSKoans. You must install PSKoans module to run or debug tests in *.Koans.ps1 files.

Should we add checks and print a better error or leave it for now? PSKoans is working on a Pester v5 -upgrade, but ETA is unclear.

@vexx32: Thoughts?