Skip to content

Commit 81145a4

Browse files
0.3.3 Release (#10)
### Fixed - Inconclusive tests are now darkorange because orange isn't a valid Spectre color.
1 parent 18675c4 commit 81145a4

File tree

7 files changed

+123
-50
lines changed

7 files changed

+123
-50
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [0.3.3] 2025-06-03
9+
10+
### Fixed
11+
12+
- Inconclusive tests are now darkorange because orange isn't a valid Spectre
13+
color.
14+
815
## [0.3.2] 2025-05-31
916

1017
### Added

PesterExplorer/PesterExplorer.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PesterExplorer.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.3.2'
15+
ModuleVersion = '0.3.3'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

PesterExplorer/Private/Format-PesterObjectName.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function Format-PesterObjectName {
6161
'Passed' { 'green' }
6262
'Failed' { 'red' }
6363
'Skipped' { 'yellow' }
64-
'Inconclusive' { 'orange' }
64+
'Inconclusive' { 'darkorange' }
6565
default { 'white' }
6666
}
6767
$finalName = if ($NoColor) {

tests/Get-PreviewPanel.tests.ps1

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ Describe 'Get-PreviewPanel' {
1515
InModuleScope $env:BHProjectName {
1616
$script:ContainerWidth = 80
1717
$script:ContainerHeight = 200
18-
$size = [Spectre.Console.Size]::new($containerWidth, $containerHeight)
19-
$script:renderOptions = [Spectre.Console.Rendering.RenderOptions]::new(
20-
[Spectre.Console.AnsiConsole]::Console.Profile.Capabilities,
21-
$size
22-
)
23-
$script:renderOptions.Justification = $null
24-
$script:renderOptions.Height = $null
2518
$container = New-PesterContainer -Scriptblock {
2619
Describe 'Demo Tests' {
2720
Context 'Contextualize It' {
@@ -69,7 +62,7 @@ Describe 'Get-PreviewPanel' {
6962
PreviewWidth = $script:ContainerWidth
7063
}
7164
$panel = Get-PreviewPanel @getPreviewPanelSplat
72-
global:Get-RenderedText -panel $panel -renderOptions $script:renderOptions -containerWidth $script:ContainerWidth |
65+
global:Get-RenderedText -Panel $panel |
7366
Should -BeLike "*Please select an item.*"
7467
}
7568
}
@@ -78,11 +71,6 @@ Describe 'Get-PreviewPanel' {
7871
InModuleScope $env:BHProjectName {
7972
$Items = Get-ListFromObject -Object $script:run.Containers[0].Blocks[0].Order[0]
8073
$height = 5
81-
$size = [Spectre.Console.Size]::new(80, $height)
82-
$renderOptions = [Spectre.Console.Rendering.RenderOptions]::new(
83-
[Spectre.Console.AnsiConsole]::Console.Profile.Capabilities,
84-
$size
85-
)
8674
$getPreviewPanelSplat = @{
8775
Items = $Items
8876
SelectedItem = 'Test1'
@@ -91,7 +79,7 @@ Describe 'Get-PreviewPanel' {
9179
PreviewWidth = $script:ContainerWidth
9280
}
9381
$panel = Get-PreviewPanel @getPreviewPanelSplat
94-
global:Get-RenderedText -panel $panel -renderOptions $renderOptions -containerWidth $script:ContainerWidth |
82+
global:Get-RenderedText -Panel $panel |
9583
Should -BeLike "*resize your terminal*"
9684
}
9785
}
@@ -106,7 +94,7 @@ Describe 'Get-PreviewPanel' {
10694
PreviewWidth = $script:ContainerWidth
10795
}
10896
$panel = Get-PreviewPanel @getPreviewPanelSplat
109-
global:Get-RenderedText -panel $panel -renderOptions $script:renderOptions -containerWidth $script:ContainerWidth |
97+
global:Get-RenderedText -panel $panel |
11098
Should -BeLike '*$true | Should -Be $true*'
11199
}
112100
}

tests/Get-TitlePanel.tests.ps1

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Describe 'Get-TitlePanel' {
22
BeforeAll {
3+
. (Join-Path $PSScriptRoot 'Helpers.ps1')
34
$manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest
45
$outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output'
56
$outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName
@@ -11,16 +12,8 @@ Describe 'Get-TitlePanel' {
1112
Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore
1213
Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop
1314

14-
InModuleScope $env:BHProjectName {
15-
$script:ContainerWidth = 80
16-
$script:ContainerHeight = 5
17-
$size = [Spectre.Console.Size]::new($containerWidth, $containerHeight)
18-
$script:renderOptions = [Spectre.Console.Rendering.RenderOptions]::new(
19-
[Spectre.Console.AnsiConsole]::Console.Profile.Capabilities,
20-
$size
21-
)
22-
$script:renderOptions.Justification = $null
23-
$script:renderOptions.Height = $null
15+
InModuleScope $env:BHProjectname {
16+
$script:pesterResult = Invoke-Pester -PassThru -Path "$PSScriptRoot\fixtures\Example.ps1" -Output 'None'
2417
}
2518
}
2619
It 'should return a Spectre.Console.Panel object' {
@@ -34,28 +27,48 @@ Describe 'Get-TitlePanel' {
3427
InModuleScope $env:BHProjectName {
3528
Mock -CommandName 'Get-Date' -MockWith { '2025-01-10 12:00:00' }
3629
$title = Get-TitlePanel
37-
$render = $title.Render($script:renderOptions, $script:ContainerWidth)
38-
# These are rendered segments.
39-
(
40-
'Pester',
41-
'Explorer',
42-
'2025-01-10',
43-
'12:00:00'
44-
) | ForEach-Object {
45-
$render.Text | Should -Contain $_
46-
}
30+
global:Get-RenderedText -Panel $title |
31+
Should -Contain 'Pester Explorer - 2025-01-10 12:00:00'
32+
}
33+
}
34+
35+
It 'should print pester run name and type' {
36+
InModuleScope $env:BHProjectName {
37+
$titleWithItem = Get-TitlePanel -Item $script:pesterResult
38+
$renderWithItem = global:Get-RenderedText -Panel $titleWithItem
39+
$renderWithItem | Should -Match 'Run: . Pester.Run'
40+
}
41+
}
42+
43+
It 'should print container name and type' {
44+
InModuleScope $env:BHProjectName {
45+
$titleWithItem = Get-TitlePanel -Item $script:pesterResult.Containers[0]
46+
$renderWithItem = global:Get-RenderedText -Panel $titleWithItem
47+
$renderWithItem | Should -BeLike '*Container:*Example.ps1'
4748
}
4849
}
4950

50-
It 'should include the Pester object type and name if provided' {
51+
It 'should print block name and type' {
5152
InModuleScope $env:BHProjectName {
52-
$pesterBlock = [Pester.Block]::Create()
53-
$pesterBlock.Name = 'Blockhead'
54-
$pesterBlock.Result = 'Failed'
55-
$titleWithItem = Get-TitlePanel -Item $pesterBlock
56-
$renderWithItem = $titleWithItem.Render($script:renderOptions, $script:ContainerWidth)
57-
$renderWithItem.Text | Should -Contain 'Block:'
58-
$renderWithItem.Text | Should -Contain 'Blockhead'
53+
$titleWithItem = Get-TitlePanel -Item $script:pesterResult.Containers[0].Blocks[0]
54+
$renderWithItem = global:Get-RenderedText -Panel $titleWithItem
55+
$renderWithItem | Should -Match 'Block: . Example Tests'
56+
}
57+
}
58+
59+
Context 'Tests' {
60+
BeforeDiscovery {
61+
$pesterResult = Invoke-Pester -PassThru -Path "$PSScriptRoot\fixtures\Example.ps1" -Output 'None'
62+
$tests = $pesterResult.Containers[0].Blocks[0].Tests
63+
}
64+
65+
It 'should print test name <_>' -ForEach $tests {
66+
InModuleScope $env:BHProjectName -ArgumentList $_ -ScriptBlock {
67+
param($test)
68+
$titleWithItem = Get-TitlePanel -Item $test
69+
$renderWithItem = global:Get-RenderedText -Panel $titleWithItem
70+
$renderWithItem | Should -Match "Test: .*$($test.Name)"
71+
}
5972
}
6073
}
6174
}

tests/Helpers.ps1

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,51 @@
1-
21
function global:Get-RenderedText {
2+
<#
3+
.SYNOPSIS
4+
Returns the rendered text from a panel object.
5+
6+
.DESCRIPTION
7+
This function processes a panel object to extract and return the rendered
8+
text. It filters out control codes and specific characters, joining the
9+
remaining text segments into a single string.
10+
11+
.PARAMETER Panel
12+
The panel object to be processed. It should have a Render method that
13+
returns a collection of text segments.
14+
15+
.PARAMETER RenderOptions
16+
Options to control the rendering of the panel. This is passed to the Render method of the panel.
17+
18+
.PARAMETER ContainerWidth
19+
The width of the container in which the panel is rendered. This is also passed to the Render method of the panel.
20+
21+
.EXAMPLE
22+
$panel = Get-PanelObject -Name "ExamplePanel"
23+
$renderOptions = Get-RenderOptions -SomeOption "Value"
24+
$containerWidth = 80
25+
$renderedText = global:Get-RenderedText -panel $panel -renderOptions $renderOptions -containerWidth $containerWidth
26+
27+
This example retrieves a panel object, specifies rendering options and
28+
container width, and then calls the function to get the rendered text.
29+
.NOTES
30+
This is a helper function we can use for our tests.
31+
#>
332
param (
4-
$panel,
5-
$renderOptions,
6-
$containerWidth
33+
[Parameter(Mandatory = $true)]
34+
#[Spectre.Console.Panel]
35+
$Panel,
36+
[Parameter()]
37+
[int]
38+
$ContainerHeight = 200,
39+
[Parameter()]
40+
[int]
41+
$ContainerWidth = 100
42+
)
43+
$size = [Spectre.Console.Size]::new($ContainerWidth, $ContainerHeight)
44+
$renderOptions = [Spectre.Console.Rendering.RenderOptions]::new(
45+
[Spectre.Console.AnsiConsole]::Console.Profile.Capabilities,
46+
$size
747
)
8-
$render = $panel.Render($renderOptions, $ContainerWidth)
48+
$render = $Panel.Render($RenderOptions, $ContainerWidth)
949

1050
# These are rendered segments.
1151
$onlyText = $render |

tests/fixtures/Example.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Describe 'Example Tests' {
2+
BeforeAll {
3+
$script:TestVariable = "Initial Value"
4+
}
5+
6+
It 'should pass' {
7+
$script:TestVariable | Should -Be "Initial Value"
8+
}
9+
10+
It 'should skip this' {
11+
Set-ItResult -Skipped 'This test is skipped intentionally.'
12+
}
13+
14+
It 'should be inconclusive' {
15+
Set-ItResult -Inconclusive 'This test is inconclusive.'
16+
}
17+
18+
It 'should be pending' {
19+
Set-ItResult -Pending 'This test is pending.'
20+
}
21+
22+
AfterAll {
23+
$script:TestVariable = $null
24+
}
25+
}

0 commit comments

Comments
 (0)