/testing-automation:pester-migrationfrom testing-automation
Upgrades PowerShell Pester test suites across major versions (v3→v4, v4→v5, v5→v6) while preserving test intent. Handles legacy syntax, Discovery/Run failures, mock migration, and PesterConfiguration adoption.
Ships in testing-automation. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Upgrade existing PowerShell Pester suites one major version at a time, using the correct migration guide for the source and target version, then rerun tests until the suite is green without changing what the tests assert.
*.Tests.ps1 and use Describe, Context, It, and Should.-SkipPublisherCheck.Load the reference for the exact jump before editing.
| Reference | When to load |
|---|---|
references/v3-to-v4.md | Should Be → Should -Be, Contain → FileContentMatch, Assert-VerifiableMocks → Assert-VerifiableMock, and array assertion edge cases. |
references/v4-to-v5.md | Discovery/Run split, BeforeAll, $PSScriptRoot, BeforeDiscovery, -ForEach, mock scoping, Should -Throw wildcards, and Invoke-Pester → New-PesterConfiguration. |
references/v5-to-v6.md | PowerShell 5.1/7.4+, per-file discovery+run, empty -ForEach, duplicate setup blocks, name <...> templates, Assert-MockCalled removal, mocks no longer fall through, code-coverage tracer, and legacy Invoke-Pester params removal. |
Canonical migration source: https://pester.dev/docs/migrations/v4-to-v5.
Run these before editing:
Get-Module Pester -ListAvailable | Select-Object Name, Version, Path
(Get-Module Pester).Version
Infer the suite's source version from code, not only the installed module.
| You see in tests or build scripts | Interpret as |
|---|---|
Should Be, Should Contain without a dash | v3 or earlier; start with references/v3-to-v4.md. |
$MyInvocation.MyCommand.Path and dot-sourcing at top level under Describe | v4; read references/v4-to-v5.md. |
Assert-MockCalled, Assert-VerifiableMock, Set-ItResult -Pending | v4 or early v5; these are removed in v6. |
Invoke-Pester -Script ... -OutputFile ... -CodeCoverage ... | Legacy invocation; map to config. |
BeforeAll { . $PSScriptRoot/... }, New-PesterConfiguration, Should -Invoke | Already v5-style; assess v5→v6. |
Install target versions deliberately:
Install-Module Pester -MaximumVersion 5.99.99 -Force
Install-Module Pester -Force
Remove-Module Pester; Import-Module Pester
Invoke-Pester on the current version and record pass/fail so migration regressions are distinguishable from pre-existing failures.Invoke-Pester -Output Detailed; for hard v4→v5 failures use -Output Diagnostic and match symptoms to the reference tables.git bisect remains useful.| Jump | Difficulty | Nature | Key work |
|---|---|---|---|
| v3 → v4 | Low | Assertion syntax rename. | Should -Be, FileContentMatch, Assert-VerifiableMock, array assertion review. |
| v4 → v5 | High | Fundamental runtime change. | Move setup into BeforeAll; discovery-time generation into BeforeDiscovery; use $PSScriptRoot; migrate Invoke-Pester to config. |
| v5 → v6 | Low–Medium | Deprecated features now throw. | Replace removed mock verbs, handle empty -ForEach, merge duplicate setup blocks, account for no mock fall-through. |
# BEFORE
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
. "$here\Get-Thing.ps1"
# AFTER
BeforeAll { . $PSScriptRoot/Get-Thing.ps1 }
BeforeDiscovery { $cases = Get-Content $PSScriptRoot/cases.json | ConvertFrom-Json }
{ throw 'a long message' } | Should -Throw '*long*'
Should -Invoke Get-Thing -Times 1 -Exactly
Should -InvokeVerifiable
Mock Get-Thing { 'default' }
Mock Get-Thing -ParameterFilter { $Name -eq 'a' } -MockWith { 'a' }
Describe 'Optional' -ForEach $cases -AllowNullOrEmptyForEach { }
Should and dot-sourcing replacements but produce false positives.*.Tests.ps1.Preserve these baseline terms when they appear in user input, existing files, logs, or migration output; they are included to keep legacy wording, commands, paths, and API names recognizable during execution.
-Output DetailedBeforeAll { . $PSScriptRoot/… }BeforeAll/BeforeEach/AfterAll/AfterEachDISCOVERSDISCOVERS/generatesForEach/-TestCasesInstall-ModuleInvoke-Pester -Script … -OutputFile … -CodeCoverage …Path/-OutputScript/-OutputFilearray-assertionbackwards-compatiblebreaking-changedata-drivendifferently-signeddot-sourceearly-v5file/concern.**find-replaceknown-goodpass/fail.passing/failingper-jumppreviously-deprecatedre-importre-runscript-automatablesymptom-driventwo-phasev3/v4PowerShellGet note: on Windows PowerShell 5.1, PowerShellGet may require -SkipPublisherCheck for side-by-side Pester installation.
## Pester migration result
**Status:** complete | needs fixes | blocked
**Source version:** <v3|v4|v5|unknown>
**Target version:** <v4|v5|v6>
### Files changed
| File | Migration applied | Validation |
| --- | --- | --- |
| `*.Tests.ps1` | <syntax/setup/mock/config change> | <pass/fail evidence> |
### Commands run
- `Get-Module Pester -ListAvailable | Select-Object Name, Version, Path`
- `Invoke-Pester <options>`
### Remaining issues
- <failure, symptom, or human decision>
references/ guide was loaded before edits.Invoke-Pester results were recorded.BeforeAll, BeforeDiscovery, $PSScriptRoot, mocks, -ForEach, and New-PesterConfiguration were handled when applicable.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
pester, powershell-testing, test-migration, unit-test-upgrade
npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin testing-automation13 skills in this plugin
/ai-prompt-engineering-safety-reviewReview and improve AI prompts for safety, bias, security, privacy, effectiveness, robustness, and testability. Use this skill when the user asks to audit a prompt, harden a system prompt, identify prompt injection risk, reduce bias, improve guardrails, or produce a safer enhanced prompt./csharp-nunitDesign, write, and review NUnit tests for .NET projects, including standard tests, data-driven tests, assertions, setup/teardown, categories, and isolation with mocks. Use this skill when the user asks for NUnit best practices, `dotnet test`, `[TestCase]`, `[TestCaseSource]`, or C# unit test structure./java-junitApply JUnit 5 best practices for Java tests, including Maven or Gradle setup, standard and parameterized tests, lifecycle hooks, assertions, Mockito isolation, tags, nested tests, and test commands. Use when asked for JUnit 5+ guidance or to write Java unit tests./javascript-typescript-jestWrite and review JavaScript and TypeScript Jest tests with strong structure, mocks, async handling, snapshots, and React Testing Library patterns. Use this skill when the user asks to add Jest tests, improve test structure, mock APIs or databases, test async code, update snapshots, or test React components./pester-should-migrationConvert classic Pester v5 `Should -...` assertions to Pester v6 `Should-*` assertion commands while preserving behavior. Use when asked to migrate, convert, rewrite, or modernize `Should -Be`, `Should -Not -Be`, `Should -Throw`, `Should -Invoke`, or other assertions in .Tests.ps1 and PowerShell files./playwright-automation-fill-in-formAutomate filling and reviewing a Microsoft Forms response with Playwright MCP. Use this skill when the user asks to open a form, fill specific fields, upload an image, or prepare but not submit a Playwright-driven form response.Other plugins' skills for the same job