Skip to content

Commit dce0ee9

Browse files
authored
Merge branch 'main' into ci/publish-recovery-gap
2 parents 179baa2 + e651a28 commit dce0ee9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/Help.tests.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,16 @@ BeforeAll {
143143
Describe "Test help for <_.Name>" -ForEach $commands {
144144

145145
BeforeDiscovery {
146-
# Get command help, parameters, and links
146+
# Get command help, parameters, and links. These are duplicated in BeforeAll
147+
# below; they must also exist here because the nested Context blocks use them in
148+
# -ForEach, which Pester evaluates during discovery (before BeforeAll runs).
147149
$command = $_
150+
$commandName = $command.Name
148151
$commandHelp = Get-Help -Name $command.Name -ErrorAction 'SilentlyContinue'
149152
$commandParameters = global:FilterOutCommonParameters -Parameters $command.ParameterSets.Parameters
150153
$commandParameterNames = $commandParameters.Name
154+
$helpParameters = global:FilterOutCommonParameters -Parameters $commandHelp.Parameters.Parameter
155+
$helpParameterNames = $helpParameters.Name
151156
$helpLinks = $commandHelp.relatedLinks.navigationLink.uri | Where-Object { $_ -match '^https?://' }
152157
}
153158

@@ -233,7 +238,7 @@ Describe "Test help for <_.Name>" -ForEach $commands {
233238

234239
# Shouldn't find extra parameters in help
235240
It 'finds help parameter in code: <_>' {
236-
$_ -in $parameterNames | Should -Be $true
241+
$_ -in $commandParameterNames | Should -Be $true
237242
}
238243
}
239244
}

0 commit comments

Comments
 (0)