Skip to content

Commit fbe0b16

Browse files
tablackburnclaude
andcommitted
fix(tests): populate help-parameter vars + commandName in BeforeDiscovery so the param-help check runs
Propagates PowerShellModuleTemplate#35. The 'help parameter help' Context used -Foreach $helpParameterNames with the variable set only in BeforeAll (run phase). Pester evaluates -Foreach during DISCOVERY, so the collection was $null then and the Context expanded to ZERO tests -- the 'no stale/extra parameters documented in help' check was a silent no-op. Populate $helpParameters/$helpParameterNames (and $commandName, used in the Context name) in BeforeDiscovery so the check actually runs. Surgical fix on current main; the broader test-scaffolding alignment (this repo's open style/align-test-scaffolding-with-template PR) remains separate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 838114d commit fbe0b16

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/Help.tests.ps1

Lines changed: 6 additions & 1 deletion
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

0 commit comments

Comments
 (0)