File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,11 +143,16 @@ BeforeAll {
143143Describe " 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}
You can’t perform that action at this time.
0 commit comments