Use when the code under test is a PowerShell script, function, cmdlet or CLI run from pwsh. Sets up Pester v5: Describe/Context/It blocks, Should assertions, Mock, setup hooks, tags, code coverage and NUnit/JUnit XML output for CI.
86%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
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