Configures Pester v5 for testing PowerShell CLIs, scripts, and cmdlets - Describe/Context/It blocks, Should assertions, Mock for isolating external dependencies, BeforeAll/BeforeEach setup hooks, Invoke-Pester with PesterConfiguration for tags, code coverage, and NUnit/JUnit XML output in CI. Use when the unit-under-test is a PowerShell script, function, or CLI tool invoked from pwsh on Windows or cross-platform.
80
100%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Longer CI pipeline definitions and the PesterConfiguration property lookup.
The core in-spine examples live in SKILL.md Steps 8 - 10; this file holds the
full CI YAML and the property table.
Run propertiesPer the configuration docs:
| Property | Default | Purpose |
|---|---|---|
Run.Path | '.' | Directory or file(s) to discover |
Run.ExcludePath | (none) | Paths to skip |
Run.Exit | $false | Non-zero exit on failure |
Run.TestExtension | '.Tests.ps1' | File filter for discovery |
One matrix job covers all three GitHub-hosted runners via pwsh (PowerShell
7+). On Windows runners -SkipPublisherCheck overrides the bundled Pester's
publisher certificate; it is a harmless no-op on Linux/macOS, where no bundled
version exists to conflict with.
jobs:
pester:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Pester
shell: pwsh
run: Install-Module -Name Pester -Force -SkipPublisherCheck
- name: Run tests
shell: pwsh
run: |
$config = New-PesterConfiguration
$config.Run.Path = '.\tests'
$config.Run.Exit = $true
$config.TestResult.Enabled = $true
$config.TestResult.OutputFormat = 'NUnitXml'
$config.TestResult.OutputPath = 'testResults.xml'
$config.CodeCoverage.Enabled = $true
$config.CodeCoverage.Path = '.\src'
$config.CodeCoverage.CoveragePercentTarget = 75
Invoke-Pester -Configuration $config
- uses: actions/upload-artifact@v4
if: always()
with:
name: pester-results
path: |
testResults.xml
coverage.xmlPer the test-results docs, after
running Pester with NUnitXml output, add a Publish Test Results task with the
NUnit format:
- task: PublishTestResults@2
inputs:
testResultsFormat: NUnit
testResultsFiles: testResults.xml