pester-migration
Helps your agent update old PowerShell tests. It adapts code for new versions, ensuring tests keep working.
What it does
This tool helps update your software tests (called Pester) for a newer version of PowerShell. It adjusts how tests are written and run to ensure they work correctly with the new versions.
When to use it
- ✓When you update your development environment to a new major PowerShell version.
- ✓When your old Pester tests stop working after an update.
- ✓To ensure your software tests are aligned with the latest tool versions.
Example of what to ask your AI
“Update my Pester tests from version 4 to 5.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The tool analyzes your existing tests and applies the necessary changes to syntax and structure. It follows specific guides for each version update, ensuring changes are made correctly.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add github/awesome-copilot --skill pester-migrationOr download just the file:
curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/pester-migration/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Pester Migration
Pester is the test framework for PowerShell. Test files end in *.Tests.ps1 and use
Describe / Context / It blocks with Should assertions. This skill upgrades an existing
suite from one major Pester version to the next and gets it green again.
Mental model: each major jump has a different character. v3→v4 is mostly a syntax rename. v4→v5 is a fundamental runtime change (the Discovery/Run split) and is the hard one. v5→v6 is largely backwards-compatible — a handful of previously-deprecated things now throw. Migrate one major at a time; never skip a version.
Detailed, symptom-driven guides live in references/ — load the one(s) for the jump you are doing.
References
| Reference | When to load |
|---|---|
| v3-to-v4.md | Should Be → Should -Be, Contain → FileContentMatch, Assert-VerifiableMocks → Assert-VerifiableMock, array-assertion edge cases. |
| v4-to-v5.md | The big one. Discovery/Run phases, BeforeAll setup, $PSScriptRoot, BeforeDiscovery, -ForEach, mock scoping, Should -Throw wildcards, Invoke-Pester → New-PesterConfiguration. |
| v5-to-v6.md | PowerShell 5.1/7.4+ only, per-file discovery+run, empty -ForEach throws, duplicate setup blocks throw, name <...> templates evaluate, Assert-MockCalled removed, mocks no longer fall through, code-coverage tracer, legacy Invoke-Pester params removed. |
Canonical source: the official migration guides at https://pester.dev/docs/migrations/ — this skill mirrors them. When in doubt, prefer the website.
Step 0 — Detect where you are and where you're going
Find the installed version(s) and the version the tests were written for. These can differ.
# Installed Pester version(s) on this machine
Get-Module Pester -ListAvailable | Select-Object Name, Version, Path
# Version currently imported in the session
(Get-Module Pester).Version
Tell the source version from the test code with these heuristics:
You see in *.Tests.ps1 / build scripts |
Suite was written for |
|---|---|
Should Be / Should Contain (no dash) |
v3 or earlier → start at v3-to-v4 |
$MyInvocation.MyCommand.Path + dot-source at the top of the file; arbitrary code directly under Describe |
v4 → v4-to-v5 |
Assert-MockCalled, Assert-VerifiableMock, Set-ItResult -Pending |
v4 / early-v5 (these are removed in v6) |
Invoke-Pester -Script … -OutputFile … -CodeCoverage … (legacy params) |
v4 invocation → map to config |
BeforeAll { . $PSScriptRoot/… }, New-PesterConfiguration, Should -Invoke |
already v5-style → v5-to-v6 |
Install the target version when ready:
# Latest stable v5 — pin the major to avoid installing Pester 6
Install-Module Pester -MaximumVersion 5.99.99 -Force
# Pester 6
Install-Module Pester -Force
On Windows PowerShell 5.1 the OS ships a Microsoft-signed built-in Pester 3 that PowerShellGet won't overwrite with the differently-signed newer Pester — add
-SkipPublisherCheckthere to install side-by-side. Not needed on PowerShell 7+. See https://pester.dev/docs/introduction/installation.
Migration workflow
Run this loop for each major jump. Do not jump two majors at once — go v4→v5, then v5→v6.
- Baseline. Run the suite on the current version first and record pass/fail. You need a
known-good (or known) starting point so you can tell migration regressions apart from
pre-existing failures.
# Bare Invoke-Pester works on every major; exact parameters differ # (v3/v4: -Script/-OutputFile; v5+/v6: -Path/-Output). Invoke-Pester - Read the reference for this jump (table above) so you know the full scope before editing.
- Edit file by file. Apply the mechanical changes (see per-jump cheat sheets below and in the reference). Keep changes small and reviewable — one file or one concern at a time.
- Switch versions with
Install-Module(Step 0), then re-import:Remove-Module Pester; Import-Module Pester(or start a fresh session). - Run and fix. Re-run with
-Output Detailed; use-Output Diagnostic(v4→v5) or read the explicit v6 error messages to locate problems. Match each failure to the symptom → fix tables in the reference.
…
FAQ
What is Pester?
Pester is a framework used for writing automated tests for code written in PowerShell. It helps verify that your code is functioning as expected.
Why do I need to update my Pester tests?
Like other software, Pester evolves. New versions may introduce changes that make tests written for older versions incompatible. Updating ensures your tests continue to work and take advantage of new features.
Can I skip versions during the update?
It is not recommended. It's best to update one major version at a time (e.g., from v3 to v4, then v4 to v5) to manage the changes more effectively and avoid complex errors.
Details
Original description by the author
Pester migration skill for upgrading PowerShell Pester test suites across major versions — v3→v4, v4→v5, and v5→v6. Covers the Discovery/Run two-phase model, moving setup into BeforeAll, $PSScriptRoot vs $MyInvocation, mock changes (Assert-MockCalled → Should -Invoke, removed fall-through), Invoke-Pester parameters → PesterConfiguration, data-driven -ForEach/-TestCases, and the v6 breaking changes
repo: github/awesome-copilot
Popularity
- GitHub stars
- 40k
- Ranking position
- #5261
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
acquire-codebase-knowledge
Helps your agent understand and document an existing code project. It's useful for onboarding new people or getting an overview of the architecture.
github/awesome-copilot
acreadiness-assess
Enables your agent to assess a project's readiness for AI and generate a report. It's useful for understanding how well a project is prepared to use AI tools.
github/awesome-copilot
acreadiness-generate-instructions
Helps your agent create instructions for AI tools based on an assessment. It's useful for improving how AI interacts with code and closing identified gaps.
github/awesome-copilot
acreadiness-policy
Enables your agent to help define or apply policies for AI project assessment. It's useful for standardizing how projects are evaluated and ensuring compliance.
github/awesome-copilot
Similar skills
cpp-testing
Makes your agent write and improve tests for C++ code. It helps set up testing tools and fix errors.
affaan-m/ECC
csharp-testing
Helps your agent create tests for C# and .NET code. It uses best practices to ensure tests are efficient and reliable.
affaan-m/ECC
django-tdd
Enables your agent to apply testing strategies for Django with pytest-django and TDD. It's useful for writing robust tests and ensuring code quality, especially for DRF APIs.
affaan-m/ECC