Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
permissions:
checks: write
pull-requests: write
contents: read
issues: write
jobs:
ci:
uses: HeyItsGilbert/.github/.github/workflows/ModuleCI.yml@main
3 changes: 1 addition & 2 deletions PesterExplorer/Public/Show-PesterResult.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ function Show-PesterResult {
$pesterResult = Invoke-Pester -Path "path\to\tests.ps1" -PassThru
Show-PesterResult -PesterResult $pesterResult

.NOTES
This function is part of the PesterExplorer module and requires Spectre.Console to be installed.
This example runs Pester tests and opens a TUI to explore the results.
#>
[CmdletBinding()]
[OutputType([void])]
Expand Down
18 changes: 18 additions & 0 deletions PesterExplorer/Public/Show-PesterResultTree.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
function Show-PesterResultTree {
<#
.SYNOPSIS
Show a Pester result in a tree format using Spectre.Console.

.DESCRIPTION
This function takes a Pester result object and formats it into a tree structure
using Spectre.Console. It is useful for visualizing the structure of Pester results
such as runs, containers, blocks, and tests.

.PARAMETER PesterResult
The Pester result object to display. This should be a Pester Run object.

.EXAMPLE
$pesterResult = Invoke-Pester -Path "path\to\tests.ps1" -PassThru
Show-PesterResultTree -PesterResult $pesterResult

This example runs Pester tests and displays the results in a tree format.
#>
[CmdletBinding()]
[OutputType([void])]
param (
Expand Down
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
],
"words": [],
"ignoreWords": [
"pwsh"
"pwsh",
"psake"
],
"import": []
}
2 changes: 1 addition & 1 deletion docs/en-US/Show-PesterResultTree.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
Aliases:

Required: False
Position: 0
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -51,7 +51,7 @@
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Check warning on line 54 in docs/en-US/Show-PesterResultTree.md

View workflow job for this annotation

GitHub Actions / ci / Run Linters

Unknown word (proga) Suggestions: (proa, prog, progs, Prog, prgo)

Required: False
Position: Named
Expand Down
2 changes: 1 addition & 1 deletion requirements.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Version = '0.6.1'
}
'PSScriptAnalyzer' = @{
Version = '1.19.1'
Version = '1.24.0'
}
'PwshSpectreConsole' = @{
Version = '2.3.0'
Expand Down
51 changes: 24 additions & 27 deletions tests/Help.tests.ps1
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
# Taken with love from @juneb_get_help (https://raw.githubusercontent.com/juneb/PesterTDD/master/Module.Help.Tests.ps1)

Check warning on line 1 in tests/Help.tests.ps1

View workflow job for this annotation

GitHub Actions / ci / Run Linters

Unknown word (juneb) Suggestions: (june, junes, June, Junes, jube)

BeforeDiscovery {

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

$manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest
$outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output'
$outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName
$outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion
$manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest

Check warning on line 12 in tests/Help.tests.ps1

View workflow job for this annotation

GitHub Actions / ci / Run Linters

Unknown word (BHPS) Suggestions: (baps, bops, bhp, BHP, bps)
$outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output'
$outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName
$outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion
$outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1"

# Get module commands
# Remove all versions of the module from the session. Pester can't handle multiple versions.
Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore
Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop
$params = @{
Module = (Get-Module $env:BHProjectName)
Module = (Get-Module $env:BHProjectName)
CommandType = [System.Management.Automation.CommandTypes[]]'Cmdlet, Function' # Not alias
}
if ($PSVersionTable.PSVersion.Major -lt 6) {
Expand All @@ -39,22 +36,22 @@

BeforeDiscovery {
# Get command help, parameters, and links
$command = $_
$commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue
$commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters
$command = $_
$commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue
$commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters
$commandParameterNames = $commandParameters.Name
$helpLinks = $commandHelp.relatedLinks.navigationLink.uri
$helpLinks = $commandHelp.relatedLinks.navigationLink.uri
}

BeforeAll {
# These vars are needed in both discovery and test phases so we need to duplicate them here
$command = $_
$commandName = $_.Name
$commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue
$commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters
$commandParameterNames = $commandParameters.Name
$helpParameters = global:FilterOutCommonParams -Params $commandHelp.Parameters.Parameter
$helpParameterNames = $helpParameters.Name
$command = $_
$commandName = $_.Name
$commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue
$commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters
$commandParameterNames = $commandParameters.Name
$helpParameters = global:FilterOutCommonParams -Params $commandHelp.Parameters.Parameter
$helpParameterNames = $helpParameters.Name
}

# If help is not found, synopsis in auto-generated help is the syntax diagram
Expand All @@ -81,12 +78,12 @@
(Invoke-WebRequest -Uri $_ -UseBasicParsing).StatusCode | Should -Be '200'
}

Context "Parameter <_.Name>" -Foreach $commandParameters {
Context "Parameter <_.Name>" -ForEach $commandParameters {

BeforeAll {
$parameter = $_
$parameterName = $parameter.Name
$parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -eq $parameterName
$parameter = $_
$parameterName = $parameter.Name
$parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -EQ $parameterName
$parameterHelpType = if ($parameterHelp.ParameterValue) { $parameterHelp.ParameterValue.Trim() }
}

Expand All @@ -107,7 +104,7 @@
}
}

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

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