Commit e9796f9
fix(tests): move Pester pin to 6.0.1 and allow empty -ForEach collections
The GitHub-hosted runner images now ship Pester 6.0.1. PSDepend imports the
pinned Pester, then PowerShellBuild's Test-PSBuildPester runs
`Import-Module Pester -MinimumVersion 5.0.0`, which resolves to the highest
installed version and collides with the already-loaded 5.7.1 DLL.
Bumping the pin exposes a second, quieter problem. Pester 6 throws on a
null/empty -ForEach by default (Run.FailOnNullOrEmptyForEach); Pester 5
quietly generated zero tests. The throw happens during discovery, so Pester
fails the entire container (the whole file). A failed container does not
increment FailedCount, and Test-PSBuildPester only throws on FailedCount --
so the build passes while that file's tests never run.
The affected collections are legitimately empty in a default module:
- $helpLinks -- a command declares no http(s) .LINK
- $commandParameters -- a command declares only common parameters
- $helpParameterNames -- likewise
- $dependencies -- RequiredModules is commented out (template default)
$commands is deliberately left strict: an empty command list means the module
failed to import and should fail loudly.
Verified by rendering the template with Initialize-Template.ps1 and running
./build.ps1 -Task Test under Pester 6.0.1:
before Tests Passed: 27, containers failed: 2 (Help.tests.ps1, Manifest.tests.ps1)
after Tests Passed: 30, containers failed: 0
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015fsEPNYeL5LKdWLDNdv3T61 parent d0f1ad8 commit e9796f9
3 files changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| |||
0 commit comments