Pester (@PSPester) header
Pester (@PSPester) profile picture

PowerShell BDD and TDD testing framework. Includes tools for function testing, module testing, mocking, code coverage and more.

Joined September 2014
Photo by Pester (@PSPester)Photo by Pester (@PSPester)Photo by Pester (@PSPester)Photo by Pester (@PSPester)Photo by Pester (@PSPester)Photo by Pester (@PSPester)Photo by Pester (@PSPester)Photo by Pester (@PSPester)Photo by Pester (@PSPester)
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
1
142
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
104
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
1
138
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
127
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
1
1
156
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
1
121
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
1
122
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
4
111
Pester 6.2.0 is out. Setup files follow your folders now. Every Pester.BeforeContainer.ps1 from the repo root down to the test file's own folder applies, outermost first, so unit tests and integration tests can each have their own setup. #pspester #powershell
1
2
5
161
Should-BeString prints a real diff. It used to put a caret under the first character that differed, so comparing a snapshot or a rendered config meant fixing one difference per run. It finds every region that differs now and prints them with context. #pspester #powershell
1
35
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
5
116
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
2
155
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
1
115
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
1
113
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
127
Pester 6: comparing objects but one field is a random id or timestamp? Should-BeEquivalent $expected -ExcludePath 'Id', 'user.name'. Dotted paths reach nested properties. #pspester #powershell
1
132
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
1
130
Pester 6: Should-BeEquivalent deep-compares objects, recursively and order-insensitive, property by property. Check a whole API response against an expected object in one line. #pspester #powershell
3
205
New in Pester 6.1: code coverage now works during parallel runs. Coverage from each worker is merged back together. Before, turning coverage on forced a sequential run. #pspester #powershell
1
111
Pester 6: Should-Throw can filter by type, message and error id at once. { ... } | Should-Throw -ExceptionType ([ArgumentException]) -ExceptionMessage '*bad*'. Type uses -is, so derived types match. #pspester #powershell
1
113
New in Pester 6.1: Should-HaveType understands PowerShell custom types, not just .NET types. Tag an object with PSTypeName 'MyApp.Person' and Should-HaveType 'MyApp.Person' passes. #pspester #powershell
1
111