From ccd076e97fc6c7132c0e0a20ba6fbf571f56a036 Mon Sep 17 00:00:00 2001 From: Trent Blackburn Date: Fri, 22 May 2026 18:58:56 -0400 Subject: [PATCH 1/2] fix(tests): populate help-parameter vars in BeforeDiscovery so the param-help check runs The 'help parameter help' Context in Help.tests.ps1 uses -Foreach $helpParameterNames, but $helpParameterNames was assigned 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 has been a silent no-op in this template and every module scaffolded from it. Fix: also populate $helpParameters/$helpParameterNames in BeforeDiscovery (mirroring $commandParameters, which already works in that same block), so the Context generates one test per documented parameter. Verified locally with Pester 5.7.1: a -Foreach collection set in BeforeDiscovery generates tests; the same collection set only in BeforeAll generates zero. Flagged by Copilot on the ReScenePS test-scaffolding-alignment PR (#18). Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/Help.tests.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/Help.tests.ps1 b/tests/Help.tests.ps1 index ea99c57..1e37e51 100644 --- a/tests/Help.tests.ps1 +++ b/tests/Help.tests.ps1 @@ -111,11 +111,15 @@ BeforeAll { Describe "Test help for <_.Name>" -ForEach $commands { BeforeDiscovery { - # Get command help, parameters, and links + # Get command help, parameters, and links. These are duplicated in BeforeAll + # below; they must also exist here because the nested Context blocks use them in + # -ForEach, which Pester evaluates during discovery (before BeforeAll runs). $command = $_ $commandHelp = Get-Help -Name $command.Name -ErrorAction 'SilentlyContinue' $commandParameters = global:FilterOutCommonParameters -Parameters $command.ParameterSets.Parameters $commandParameterNames = $commandParameters.Name + $helpParameters = global:FilterOutCommonParameters -Parameters $commandHelp.Parameters.Parameter + $helpParameterNames = $helpParameters.Name $helpLinks = $commandHelp.relatedLinks.navigationLink.uri | Where-Object { $_ -match '^https?://' } } From c7ea4580f2a0f0995ff16fa691d89865f218395d Mon Sep 17 00:00:00 2001 From: Trent Blackburn Date: Fri, 22 May 2026 19:56:55 -0400 Subject: [PATCH 2/2] fix(tests): set $commandName in BeforeDiscovery for the now-discovered Context name The 'Test <_> help parameter help for ' Context name expands at discovery, but $commandName was only set in BeforeAll. Now that the prior fix makes this Context actually get discovered, populate $commandName in BeforeDiscovery too so the generated test names render correctly. Flagged by Copilot on #35. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/Help.tests.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Help.tests.ps1 b/tests/Help.tests.ps1 index 1e37e51..7cf307c 100644 --- a/tests/Help.tests.ps1 +++ b/tests/Help.tests.ps1 @@ -115,6 +115,7 @@ Describe "Test help for <_.Name>" -ForEach $commands { # below; they must also exist here because the nested Context blocks use them in # -ForEach, which Pester evaluates during discovery (before BeforeAll runs). $command = $_ + $commandName = $command.Name $commandHelp = Get-Help -Name $command.Name -ErrorAction 'SilentlyContinue' $commandParameters = global:FilterOutCommonParameters -Parameters $command.ParameterSets.Parameters $commandParameterNames = $commandParameters.Name