Skip to content

Commit 4fb92b4

Browse files
committed
feat(Get-PreviewPanel): 🎨 add breakdown chart for Pester object results
* Implemented a breakdown chart displaying the counts of Passed, Failed, Inconclusive, and Skipped tests. * Added a check to skip chart generation if the object is null or has all zero counts. * Remove breakdown from title. It was too messy.
1 parent 66bc83b commit 4fb92b4

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

‎PesterExplorer/Private/Get-PreviewPanel.ps1‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ function Get-PreviewPanel {
6666
# SelectedItem can be a few different types:
6767
# - A Pester object (Run, Container, Block, Test)
6868

69+
#region Breakdown
70+
# Skip if the object is null or they are all zero.
71+
if (
72+
(
73+
$object.PassedCount +
74+
$object.InconclusiveCount +
75+
$object.SkippedCount +
76+
$object.FailedCount
77+
) -gt 0
78+
) {
79+
$data = @()
80+
$data += New-SpectreChartItem -Label "Passed" -Value ($object.PassedCount) -Color "Green"
81+
$data += New-SpectreChartItem -Label "Failed" -Value ($object.FailedCount) -Color "Red"
82+
$data += New-SpectreChartItem -Label "Inconclusive" -Value ($object.InconclusiveCount) -Color "Grey"
83+
$data += New-SpectreChartItem -Label "Skipped" -Value ($object.SkippedCount) -Color "Yellow"
84+
$result += Format-SpectreBreakdownChart -Data $data
85+
}
86+
#endregion Breakdown
87+
6988
# For Tests Let's print some more details
7089
if ($object.GetType().Name -eq "Test") {
7190
$formatSpectrePanelSplat = @{

‎PesterExplorer/Private/Get-TitlePanel.ps1‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ function Get-TitlePanel {
3535
$title += " | $($Item.GetType().Name): $($objectName)"
3636
}
3737
$rows += $title
38-
#region Breakdown
39-
$data = @()
40-
$data += New-SpectreChartItem -Label "Passed" -Value ($Item.PassedCount) -Color "Green"
41-
$data += New-SpectreChartItem -Label "Inconclusive" -Value ($Item.InconclusiveCount) -Color "Grey"
42-
$data += New-SpectreChartItem -Label "Skipped" -Value ($Item.SkippedCount) -Color "Yellow"
43-
$data += New-SpectreChartItem -Label "Failed" -Value ($Item.FailedCount) -Color "Red"
44-
$rows += Format-SpectreBreakdownChart -Data $data -ShowPercentage
45-
#endregion Breakdown
4638

4739
return $rows | Format-SpectreRows |
4840
Format-SpectreAligned -HorizontalAlignment Center -VerticalAlignment Middle |

0 commit comments

Comments
 (0)