Support Pester v5.0.x invocation
Before submitting a bug report, please ensure you :
- [x] Verified this bug is not already reported in an issue
- [x] Can reproduce in a clean PowerShell session (clean =
powershell -NoProfile)
Describe the Problem
Throws warnings and quite likely does not work properly with Pester v5.0 Pester v5.0 changed from command line switches, hashtables, etc. to a single Configuration nested hashtable object.
Steps To Reproduce
- Import-Module Pester -RequiredVersion 5.0.4
- Run Invoke-PSCodeHealth -Path .\src -TestsPath .\tests
- Error or unexpected behavior :
WARNING: You are using Legacy parameter set that adapts Pester 5 syntax to Pester 4 syntax. This parameter set is
deprecated, and does not work 100%. The -Strict and -PesterOption parameters are ignored, and providing advanced
configuration to -Path (-Script), and -CodeCoverage via a hash table does not work. Please refer to
https://github.com/pester/Pester/releases/tag/5.0.1#legacy-parameter-set for more information.
Resolve-CoverageInfo : Could not resolve coverage path 'System.Collections.Hashtable': Cannot find path
'...\System.Collections.Hashtable' because it does not exist.
At C:\Program Files\WindowsPowerShell\Modules\pester\5.0.4\Pester.psm1:7149 char:5
+ Resolve-CoverageInfo -UnresolvedCoverageInfo $unresolvedCoverageI ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Resolve-CoverageInfo
Expected behavior
PSCodeHealth should detect the Pester version and invoke the command properly.
Environment
- Operating system : Windows10
- PowerShell version : 5.1.18362.1110
- PSCodeHealth version : 0.2.26
- Pester: 5.0.4
Additional context
How has this issue affected you ? Prevents us from migrating to new version of Pester. What are you trying to accomplish ? Basic functionality advertised by the package. Providing context helps us come up with a solution that is most useful and prioritize issues.
You can also provide a -TestResult to Invoke-PSCodeHealth. So run your Pester 5 tests with -PassThru and then pipe that into ConvertTo-Pester4Result. You do have to manage the currently imported version of Pester though.
Import-Module Pester -MinimumVersion 5.0.0
$configuration = [PesterConfiguration]::Default
$configuration.Run.Path = $TestPath
$configuration.Run.PassThru = $true
$testResult = Invoke-Pester -Configuration $configuration | ConvertTo-Pester4Result
Remove-Module Pester -Force
Import-Module Pester -MaximumVersion 4.*
Invoke-PSCodeHealth -Path $CodePath -TestsResult $testResult