Skip to content

Commit 4409e90

Browse files
committed
docs: ✏️ update documentation and examples for Show-PesterResult and Show-PesterResultTree
* Added example usage for `Show-PesterResult` to demonstrate TUI exploration of Pester results. * Enhanced `Show-PesterResultTree` documentation with a new example and adjusted parameter position. * Updated `cspell.json` to include "psake" in ignored words list.
1 parent 45bc20f commit 4409e90

File tree

5 files changed

+46
-31
lines changed

5 files changed

+46
-31
lines changed

PesterExplorer/Public/Show-PesterResult.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ function Show-PesterResult {
1717
$pesterResult = Invoke-Pester -Path "path\to\tests.ps1" -PassThru
1818
Show-PesterResult -PesterResult $pesterResult
1919
20-
.NOTES
21-
This function is part of the PesterExplorer module and requires Spectre.Console to be installed.
20+
This example runs Pester tests and opens a TUI to explore the results.
2221
#>
2322
[CmdletBinding()]
2423
[OutputType([void])]

PesterExplorer/Public/Show-PesterResultTree.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
function Show-PesterResultTree {
2+
<#
3+
.SYNOPSIS
4+
Show a Pester result in a tree format using Spectre.Console.
5+
6+
.DESCRIPTION
7+
This function takes a Pester result object and formats it into a tree structure
8+
using Spectre.Console. It is useful for visualizing the structure of Pester results
9+
such as runs, containers, blocks, and tests.
10+
11+
.PARAMETER PesterResult
12+
The Pester result object to display. This should be a Pester Run object.
13+
14+
.EXAMPLE
15+
$pesterResult = Invoke-Pester -Path "path\to\tests.ps1" -PassThru
16+
Show-PesterResultTree -PesterResult $pesterResult
17+
18+
This example runs Pester tests and displays the results in a tree format.
19+
#>
220
[CmdletBinding()]
321
[OutputType([void])]
422
param (

cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
],
88
"words": [],
99
"ignoreWords": [
10-
"pwsh"
10+
"pwsh",
11+
"psake"
1112
],
1213
"import": []
1314
}

docs/en-US/Show-PesterResultTree.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Parameter Sets: (All)
3939
Aliases:
4040

4141
Required: False
42-
Position: 0
42+
Position: 1
4343
Default value: None
4444
Accept pipeline input: False
4545
Accept wildcard characters: False

tests/Help.tests.ps1

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,23 @@ BeforeDiscovery {
44

55
function global:FilterOutCommonParams {
66
param ($Params)
7-
$commonParams = @(
8-
'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable',
9-
'OutBuffer', 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction',
10-
'WarningVariable', 'Confirm', 'Whatif'
11-
)
12-
$params | Where-Object { $_.Name -notin $commonParams } | Sort-Object -Property Name -Unique
7+
$commonParameters = [System.Management.Automation.PSCmdlet]::CommonParameters +
8+
[System.Management.Automation.PSCmdlet]::OptionalCommonParameters
9+
$params | Where-Object { $_.Name -notin $commonParameters } | Sort-Object -Property Name -Unique
1310
}
1411

15-
$manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest
16-
$outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output'
17-
$outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName
18-
$outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion
12+
$manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest
13+
$outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output'
14+
$outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName
15+
$outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion
1916
$outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1"
2017

2118
# Get module commands
2219
# Remove all versions of the module from the session. Pester can't handle multiple versions.
2320
Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore
2421
Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop
2522
$params = @{
26-
Module = (Get-Module $env:BHProjectName)
23+
Module = (Get-Module $env:BHProjectName)
2724
CommandType = [System.Management.Automation.CommandTypes[]]'Cmdlet, Function' # Not alias
2825
}
2926
if ($PSVersionTable.PSVersion.Major -lt 6) {
@@ -39,22 +36,22 @@ Describe "Test help for <_.Name>" -ForEach $commands {
3936

4037
BeforeDiscovery {
4138
# Get command help, parameters, and links
42-
$command = $_
43-
$commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue
44-
$commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters
39+
$command = $_
40+
$commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue
41+
$commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters
4542
$commandParameterNames = $commandParameters.Name
46-
$helpLinks = $commandHelp.relatedLinks.navigationLink.uri
43+
$helpLinks = $commandHelp.relatedLinks.navigationLink.uri
4744
}
4845

4946
BeforeAll {
5047
# These vars are needed in both discovery and test phases so we need to duplicate them here
51-
$command = $_
52-
$commandName = $_.Name
53-
$commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue
54-
$commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters
55-
$commandParameterNames = $commandParameters.Name
56-
$helpParameters = global:FilterOutCommonParams -Params $commandHelp.Parameters.Parameter
57-
$helpParameterNames = $helpParameters.Name
48+
$command = $_
49+
$commandName = $_.Name
50+
$commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue
51+
$commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters
52+
$commandParameterNames = $commandParameters.Name
53+
$helpParameters = global:FilterOutCommonParams -Params $commandHelp.Parameters.Parameter
54+
$helpParameterNames = $helpParameters.Name
5855
}
5956

6057
# If help is not found, synopsis in auto-generated help is the syntax diagram
@@ -81,12 +78,12 @@ Describe "Test help for <_.Name>" -ForEach $commands {
8178
(Invoke-WebRequest -Uri $_ -UseBasicParsing).StatusCode | Should -Be '200'
8279
}
8380

84-
Context "Parameter <_.Name>" -Foreach $commandParameters {
81+
Context "Parameter <_.Name>" -ForEach $commandParameters {
8582

8683
BeforeAll {
87-
$parameter = $_
88-
$parameterName = $parameter.Name
89-
$parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -eq $parameterName
84+
$parameter = $_
85+
$parameterName = $parameter.Name
86+
$parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -EQ $parameterName
9087
$parameterHelpType = if ($parameterHelp.ParameterValue) { $parameterHelp.ParameterValue.Trim() }
9188
}
9289

@@ -107,7 +104,7 @@ Describe "Test help for <_.Name>" -ForEach $commands {
107104
}
108105
}
109106

110-
Context "Test <_> help parameter help for <commandName>" -Foreach $helpParameterNames {
107+
Context "Test <_> help parameter help for <commandName>" -ForEach $helpParameterNames {
111108

112109
# Shouldn't find extra parameters in help.
113110
It "finds help parameter in code: <_>" {

0 commit comments

Comments
 (0)