Pester module: setup and commands
Documentation: Microsoft Learn
Write repeatable PowerShell tests with Describe, It and Should, then isolate dependencies with mocks that target the command actually called.
Getting it
A Pester 3.4 copy ships with Windows, so install the current release side by side using Install-PSResource -Name Pester and import the version you want explicitly.
Examples
Show reference output
What it is for
Use it to pin down behavior on functions and modules before refactoring them. It also makes infrastructure assertions practical, since a test can check that a service is running or a certificate is still valid.
Typical tasks
- Assert the shape and values of function output
- Mock a cmdlet so tests never touch production
- Fail a CI build when a regression appears
- Produce NUnit XML for a test report
- Measure code coverage across a module
- Validate infrastructure state as a test
Check the installed version
Compare the module path and version with the session used by your scheduled task or automation account. Use it to pin down behavior on functions and modules before refactoring them. It also makes infrastructure assertions practical, since a test can check that a service is running or a certificate is still valid.