Skip to content

Commit 98d5714

Browse files
🩹 [Patch]: Fix output formatting with Out-String (#22)
## Description This pull request includes multiple changes to the PowerShell scripts to ensure that formatted output is converted to strings. ### Changes to ensure formatted output is converted to strings * Added `Out-String` to the `Format-List` and `Format-Table` commands to avoid getting text wrapped or cut of. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 21851bb commit 98d5714

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

scripts/init.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ LogGroup 'Init - Load inputs' {
8484
TestRegistry_Enabled = $env:PSMODULE_INVOKE_PESTER_INPUT_TestRegistry_Enabled
8585
}
8686

87-
[pscustomobject]($inputs.GetEnumerator() | Where-Object { -not [string]::IsNullOrEmpty($_.Value) }) | Format-List
87+
[pscustomobject]($inputs.GetEnumerator() | Where-Object { -not [string]::IsNullOrEmpty($_.Value) }) | Format-List | Out-String
8888
}
8989

9090
LogGroup 'Init - Load configuration - Defaults' {
91-
Write-Output (New-PesterConfigurationHashtable -Default | Format-Hashtable | Out-String)
91+
New-PesterConfigurationHashtable -Default | Format-Hashtable | Out-String
9292
}
9393

9494
LogGroup 'Init - Load configuration - Custom settings file' {

scripts/main.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $pesterModule = Get-PSResource -Name Pester -Verbose:$false | Sort-Object Versio
2020

2121
'::group::Exec - Import Configuration'
2222
$configuration = & "$PSScriptRoot/Invoke-Pester.Configuration.ps1"
23-
$configuration
23+
$configuration | Out-String
2424
$configuration.Run.Container = @()
2525
$containerFiles = Get-ChildItem -Path $PSScriptRoot -Filter *.Container.* -Recurse | Sort-Object FullName
2626
foreach ($containerFile in $containerFiles) {
@@ -33,7 +33,7 @@ $configuration.Run.Container | ConvertTo-Json
3333
'::endgroup::'
3434

3535
'::group::Exec - Available modules'
36-
Get-Module | Format-Table -AutoSize
36+
Get-Module | Format-Table -AutoSize | Out-String
3737
'::endgroup::'
3838

3939
$configuration = New-PesterConfiguration -Hashtable $configuration
@@ -62,7 +62,7 @@ LogGroup 'Eval - Test results' {
6262
exit 1
6363
}
6464

65-
$testResults | Format-List
65+
$testResults | Format-List | Out-String
6666
}
6767

6868
LogGroup 'Eval - Test results summary' {
@@ -81,7 +81,7 @@ LogGroup 'Eval - Set outputs' {
8181
TestResultOutputPath = $testResults.Configuration.TestResult.OutputPath.Value
8282
CodeCoverageEnabled = $testResults.Configuration.CodeCoverage.Enabled.Value
8383
CodeCoverageOutputPath = $testResults.Configuration.CodeCoverage.OutputPath.Value
84-
} | Format-List
84+
} | Format-List | Out-String
8585
}
8686

8787
LogGroup 'Exit' {

0 commit comments

Comments
 (0)