Checklist
What is the issue?
Name expansion in Pester v6 "hangs" when referencing complex objects with many properties like CommandInfo.
Cause: Getting stuck in recursion with Format-Nicely2-> Format-Object2 -> Format-Nicely2 .. looping properties.
Expected Behavior
Not hang.
Steps To Reproduce
Describe 'Infinite format loop?' {
BeforeAll {
$func = Get-Command -Name 'Invoke-Pester'
}
it '<func.name> is cool' {
$func.Name | Should -Be 'Invoke-Pester'
}
it '<func> will hang' {
$func.Name | Should -Be 'Invoke-Pester'
}
}
Or just & (Get-Module Pester) { Format-Nicely2 (Get-Command Invoke-Pester) }
Describe your environment
# Began in Pester 6.0.0
Pester version : 6.1.0-alpha2 /workspaces/Pester/bin/Pester.psm1
PowerShell version : 7.4.16
OS version : Unix 6.18.35.2
Possible Solution?
Guidance: Test authors should reference the string-property, like <mycommandinfo.name>
Technical: We should have some guardrails to avoid errors. Restrict Format-NicelyForTemplate to 0 or 1 level of recursion. Anything else gets messy.
We could also special case CommandInfo to [string] cast like v5, but do we want to? Without deep format, v6 will return [Management.Automation.FunctionInfo] in this scenario. That would help authors identify a bad practice and fix it.
Checklist
What is the issue?
Name expansion in Pester v6 "hangs" when referencing complex objects with many properties like
CommandInfo.Cause: Getting stuck in recursion with
Format-Nicely2->Format-Object2->Format-Nicely2.. looping properties.Expected Behavior
Not hang.
Steps To Reproduce
Or just
& (Get-Module Pester) { Format-Nicely2 (Get-Command Invoke-Pester) }Describe your environment
Possible Solution?
Guidance: Test authors should reference the string-property, like
<mycommandinfo.name>Technical: We should have some guardrails to avoid errors. Restrict
Format-NicelyForTemplateto 0 or 1 level of recursion. Anything else gets messy.We could also special case
CommandInfoto[string]cast like v5, but do we want to? Without deep format, v6 will return[Management.Automation.FunctionInfo]in this scenario. That would help authors identify a bad practice and fix it.