diff --git a/src/functions/Output.ps1 b/src/functions/Output.ps1 index 8ce6e74ed..e9b769d2f 100644 --- a/src/functions/Output.ps1 +++ b/src/functions/Output.ps1 @@ -652,7 +652,7 @@ function Get-WriteScreenPlugin ($Verbosity) { param ($Context) if ($Context.Result.ErrorRecord.Count -gt 0) { - $errorHeader = "[-] $($Context.Result.Item) failed with:" + $errorHeader = "[-] $($Context.Result.Name) failed with:" $formatErrorParams = @{ Err = $Context.Result.ErrorRecord @@ -673,13 +673,13 @@ function Get-WriteScreenPlugin ($Verbosity) { $humanTime = "$(Get-HumanTime ($Context.Result.Duration)) ($(Get-HumanTime $Context.Result.UserDuration)|$(Get-HumanTime $Context.Result.FrameworkDuration))" if ($Context.Result.Passed) { - Write-PesterHostMessage -ForegroundColor $ReportTheme.Pass "[+] $($Context.Result.Item)" -NoNewLine + Write-PesterHostMessage -ForegroundColor $ReportTheme.Pass "[+] $($Context.Result.Name)" -NoNewLine Write-PesterHostMessage -ForegroundColor $ReportTheme.PassTime " $humanTime" } # this won't work skipping the whole file when all it's tests are skipped is not a feature yet in 5.0.0 if ($Context.Result.Skip) { - Write-PesterHostMessage -ForegroundColor $ReportTheme.Skipped "[!] $($Context.Result.Item)" -NoNewLine + Write-PesterHostMessage -ForegroundColor $ReportTheme.Skipped "[!] $($Context.Result.Name)" -NoNewLine Write-PesterHostMessage -ForegroundColor $ReportTheme.SkippedTime " $humanTime" } } diff --git a/tst/Pester.RSpec.InNewProcess.ts.ps1 b/tst/Pester.RSpec.InNewProcess.ts.ps1 index ebc4cffb7..44f2a3585 100644 --- a/tst/Pester.RSpec.InNewProcess.ts.ps1 +++ b/tst/Pester.RSpec.InNewProcess.ts.ps1 @@ -384,7 +384,7 @@ i -PassThru:$PassThru { $ps.HadErrors | Verify-False $res.PassedCount | Verify-Equal 1 # Information-stream introduced in PSv5 for Write-Host output - if ($PSVersionTable.PSVersion.Major -ge 5) { $ps.Streams.Information -match 'Describe' | Verify-NotNull } + if ($PSVersionTable.PSVersion.Major -ge 5) { $ps.Streams.Information -match '' | Verify-NotNull } } finally { $ps.Dispose() diff --git a/tst/Pester.RSpec.Output.ts.ps1 b/tst/Pester.RSpec.Output.ts.ps1 index f921dd1e8..9b32ec802 100644 --- a/tst/Pester.RSpec.Output.ts.ps1 +++ b/tst/Pester.RSpec.Output.ts.ps1 @@ -222,6 +222,34 @@ i -PassThru:$PassThru { } } + b 'Output for container names' { + t 'Script Block container names are output when BeforeAll fails' { + $sb = { + $PesterPreference = [PesterConfiguration]::Default + $PesterPreference.Output.Verbosity = 'Detailed' + $PesterPreference.Output.RenderMode = 'ConsoleColor' + + $container = New-PesterContainer -ScriptBlock { + BeforeAll { + throw 'bad error' + } + Describe 'd1' { + It 'i1' { + 1 | Should -Be 1 + } + } + } + Invoke-Pester -Container $container + } + + $output = Invoke-InNewProcess $sb + $null, $run = $output -join "`n" -split 'Running tests.' + $run | Write-Host + + $run | Verify-Like '*[-]** failed with:*' + } + } + b 'Write-PesterHostMessage' { t 'Ansi output includes colors when set and always reset' { $sb = {