A no-inherit comment at the top of a folder's Pester.BeforeContainer.ps1 stops the chain there, so no setup file above that folder applies to it. Same meaning root = true has in editorconfig. New in 6.2.
#pspester #powershell
Run.Parallel needed ForEach-Object -Parallel, a PowerShell 7 cmdlet, so Windows PowerShell 5.1 ran sequentially. Pester 6.2 uses the runspace pool API both editions ship, so 5.1 runs parallel. Experimental.
#pspester #powershell
BeforeAll threw and Pester blamed a break or continue statement escaping your code? In 6.1 the real exception was discarded. In 6.2 you get the error that actually threw, with the line it came from.
#pspester #powershell
In 6.2 every folder down to your test file can have its own Pester.BeforeContainer.ps1, applied outermost first, so tests/unit and tests/integration each add their own setup on top of the shared root one.
#pspester #powershell
In 6.2 top level code in Pester.BeforeContainer.ps1 runs during discovery only. To reach your tests it has to sit inside BeforeAll, the same rule your test files follow. Wrap a bare Import-Module or it is not there.
#pspester #powershell
A dead worker in a parallel run takes its whole test file with it. Pester 6.2 checks that every file came back and fails the run, naming the one that did not. Before, the suite went green one file short.
#pspester #powershell
A second BeforeAll in the same block threw in 6.1. In 6.2 a block takes as many BeforeAll and AfterAll as you want, setups running in the order you wrote them and teardowns in reverse.
#pspester #powershell
Your Pester.BeforeContainer.ps1 silently not applying? In 6.1 Pester found the repo root from the process working directory, which Set-Location does not change. In 6.2 it starts from where your session is.
#pspester #powershell
An error thrown from inside Pester lost its whole stack trace and printed no location at all. A BeforeAll that failed because a database was down reported an escaped break statement instead. Failures point at the line that caused them now. #pspester #powershell
Run.Parallel works on Windows PowerShell 5.1, not just PowerShell 7. It was built on ForEach-Object -Parallel, both editions go through a runspace pool now. 5.1 is the slowest edition, so it is the one that needed it most.
github.com/pester/Pester/rel… #pspester #powershell
Pester 6 catches a classic bug: -ForEach with an empty array used to skip silently. Now it fails discovery, so tests that never ran do not look green. Opt out with -AllowNullOrEmptyForEach. #pspester #powershell
Pester 6: assert on speed. { Start-Sleep -Milliseconds 100 } | Should-BeFasterThan 1s. Time literals like 1s and 50ms just work, and Should-BeSlowerThan is the opposite. #pspester #powershell
Pester 6: check your function's public contract. Get-Command My-Func | Should-HaveParameter Name -Type ([string]) -Mandatory. It reads the real parameter metadata: type, mandatory, default, alias, set. #pspester #powershell
Pester 6: run an assertion over every item. 1,2,3 | Should-All { $_ | Should-BeGreaterThan 0 }. A nested Should failure counts as that item failing, and Pester tells you which one. #pspester #powershell
Pester 6: Should-BeCollection compares by contents and ignores the concrete type, so an object[] and a List[int] with the same items are equal. Or check only the size with -Count 3. #pspester #powershell
New in Pester 6.1: drop a Pester.BeforeContainer.ps1 at your repo root and Pester dot-sources it into every test file before it runs. Handy for parallel runs that start from clean runspaces. #pspester #powershell
