Repository navigation
Conversation
`build.requires.psd1` capped Pester at `:[5.0, 6.0)`, so ModuleFast never installed 6.x. Widening the range to `:[5.0, 7.0)` is not enough on its own, because Pester 6 removed `Assert-MockCalled`, which 5 test files used 20 times. Those are now `Should -Invoke`, which exists in Pester 5 as well, so the tests run unchanged on both. `Tests/Private/ImportBase64Module.Tests.ps1` needed more than a rename. It set `"Assert-MockCalled:ModuleName"` in `$PSDefaultParameterValues`, and the equivalent key for the new command would be `"Should:ModuleName"`, which would apply to every `Should` call in the file. The two call sites pass `-ModuleName ModuleBuilder` explicitly instead. 🤖
The comment claimed a "Should:ModuleName" default would apply to every Should call, as if that were a hazard. It does apply to every call, and it is harmless: -ModuleName belongs to the Invoke and InvokeVerifiable parameter sets, and the other sets ignore the default. A plain `1 | Should -Be 1` passes with the key set, on 5.9.1 and on 6.2.0, and gaelcolas/Sampler's own test template sets it on purpose. Passing -ModuleName on the two Should -Invoke calls is still the clearer choice, so the code is unchanged. Only the reason was wrong. 🤖
Author
|
Correcting myself on the comment I put in Passing 🤖 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
build.requires.psd1caps Pester at:[5.0, 6.0), so ModuleFast never installs 6.x. Widening the range alone does not work: Pester 6 removedAssert-MockCalled, and 5 test files use it 20 times.This does both. The range becomes
:[5.0, 7.0), the assertions becomeShould -Invoke. That command exists in Pester 5 too, so the range stays wide and the tests run on either version.Tests/Private/ImportBase64Module.Tests.ps1needed more than a rename:Should -Invokeis theShouldcommand, so the matching key is"Should:ModuleName", which would hit everyShouldcall in the file. The two call sites pass-ModuleName ModuleBuilderinstead.-Times 0keeps its meaning. Pester treats it as exact even without-Exactly(Mock.ps1:$matchingCalls.Count -ne $Times -and ($Exactly -or ($Times -eq 0))), so the two-Times 0assertions inCopyReadMe.Tests.ps1still mean "never called".Full
Testsdirectory on macOS, each version in its own process: 235 passed and 0 failed on 5.9.1, the same on 6.2.0. I could not run it on Windows, CI only triggers onmain.test.ps1requiresMaximumVersion 4.999and callsInvoke-Pester -Show/-PesterOption, both gone since Pester 5. Separate change?Templates/Dotnet/ModuleBuilderModule/RequiredModules.psd1pins[4.7.2, 5.0), so generated modules still get Pester 4.🤖