Skip to content
github/awesome-copilot

Upgrading Pester Test Suites for PowerShell Across Major Versions

Claude CodeGitHub CopilotOpenAI CodexCursorDevin / WindsurfGemini CLI

About this skill

A skill documenting how to upgrade Pester test suites for the PowerShell testing framework across major versions: v3→v4, v4→v5, and v5→v6. It covers the two-phase (discovery/run) execution model, moving setup into BeforeAll, replacing $MyInvocation with $PSScriptRoot, mocking changes (Assert-MockCalled → Should -Invoke), converting Invoke-Pester parameters to PesterConfiguration, and data-driven tests via -ForEach/-TestCases, along with the breaking changes in v6. The primary reference is the official upgrade guides on pester.dev.
Start here

How do you use this skill?

1. Determine the installed Pester version and the version the tests were written for by inspecting *.Tests.ps1 files (e.g., the presence of Should Be without a dash indicates v3). 2. Run the suite on the current version first to record a baseline of passes and failures. 3. Read the appropriate upgrade guide for the desired jump from the references folder (one major jump at a time, without skipping any version). 4. Edit the files one by one, applying the mechanical changes: converting Should Be to Should -Be, moving imports into BeforeAll with $PSScriptRoot, moving test generation into BeforeDiscovery, and replacing old Invoke-Pester parameters with New-PesterConfiguration. 5. Re-run the tests with Detailed or Diagnostic output and match each failure against the 'Symptom → Fix' tables in the guide. 6. Repeat until the result matches the baseline, then review the differences and commit each file. Example user request: 'My Tests.ps1 files stopped working after upgrading Pester to v5 — fix my tests wrapped in foreach and my old Invoke-Pester command'.

Requirements and limitations

Requires a PowerShell environment with the Pester module installed (both the current and target versions); v6 requires running only on Windows PowerShell 5.1 or PowerShell 7.4+. Assumes the presence of *.Tests.ps1 test files and the ability to run Invoke-Pester and Install-Module. The skill does not support PowerShell 2 (removed in v5) or PowerShell 3/4/6 with v6, and Gherkin was removed in v5. Migration must be done one major jump at a time, and the skill does not change what the test asserts, only its structure and how it is invoked; automated migration scripts may produce incorrect results and require manual review, while preserving file encodings.

Installation by agent

Download and extract the ZIP. It contains the folder pester-migration and the file SKILL.md with the original attachments and license.

Claude Code
  1. Create this path inside your project if it does not exist:.claude/skills/
  2. Copy the entire extracted skill folder to this path:.claude/skills/pester-migration/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for pester-migration.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide Claude Code official documentation ↗
GitHub Copilot
  1. Create this path inside your project if it does not exist:.github/skills/
  2. Copy the entire extracted skill folder to this path:.github/skills/pester-migration/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for pester-migration.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide GitHub Copilot official documentation ↗
OpenAI Codex
  1. Create this path inside your project if it does not exist:.agents/skills/
  2. Copy the entire extracted skill folder to this path:.agents/skills/pester-migration/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for pester-migration.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide OpenAI Codex official documentation ↗
Cursor
  1. Create this path inside your project if it does not exist:.cursor/skills/
  2. Copy the entire extracted skill folder to this path:.cursor/skills/pester-migration/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for pester-migration.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide Cursor official documentation ↗
Devin / Windsurf
  1. Create this path inside your project if it does not exist:.devin/skills/
  2. Copy the entire extracted skill folder to this path:.devin/skills/pester-migration/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for pester-migration.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide Devin / Windsurf official documentation ↗
Gemini CLI
  1. Create this path inside your project if it does not exist:.gemini/skills/
  2. Copy the entire extracted skill folder to this path:.gemini/skills/pester-migration/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for pester-migration.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide Gemini CLI official documentation ↗

Original files retain their language to preserve tool names and paths. Compatibility is classified by review, not runtime testing on every agent version.