pester-should-migration

Converts Pester v5 Should -Be assertions to Pester v6 Should-* syntax in PowerShell test files.

38.5k|4.9k|Updated Jun 11, 2025
One-click install
npx skills add https://github.com/github/awesome-copilot --skill pester-should-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pester-should-migration
Source: https://github.com/github/awesome-copilot/tree/main/skills/pester-should-migration
Command: npx skills add https://github.com/github/awesome-copilot --skill pester-should-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Migrating a Pester test suite from classic v5 assertions (Should -Be, Should -Not -Be) to the new v6 Should-* operators is error-prone: many operators were renamed, negation became separate commands, and several assertions changed behavior (truthy vs. strict booleans, collection handling, case sensitivity). This Skill provides a verified mapping and procedure to convert assertions without silently breaking tests.

Core Features & Use Cases

  • Operator-by-operator mapping: Converts classic assertions like Should -BeExactly to Should-BeString -CaseSensitive and Should -BeGreaterOrEqual to Should-BeGreaterThanOrEqual, with a full reference table in references/assertion-map.md.
  • Behavioral gotcha detection: Flags conversions that are not plain renames, such as Should -BeTrue (truthy) vs. Should-BeTrue (strict), Should -BeNullOrEmpty splitting by intent, and collection comparisons requiring Should-BeCollection.
  • Verification and enforcement: Runs Invoke-Pester to confirm the suite stays green and optionally sets Should.DisableV5 to prevent classic syntax from creeping back.
  • Use Case: A team upgrading to Pester 6 asks to modernize all *.Tests.ps1 files; the Skill converts hundreds of Should -... calls, rewrites Assert-MockCalled to Should-Invoke, and reports assertions needing human decisions.

Quick Start

Migrate all classic Should assertions in my tests folder to the new Pester v6 Should-* syntax and run the suite to verify nothing broke.

Frequently Asked Questions about pester-should-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Pester v5 Should assertions to v6?

Search your *.Tests.ps1 files for the classic `Should -` pattern, then apply the operator mapping: most become plain renames like `Should -Be` to `Should-Be`, while negations become separate commands like `Should-NotBe`. Run Invoke-Pester afterward to confirm the suite stays green.

What is the difference between Should-BeTrue and Should-BeTruthy in Pester v6?

Should-BeTrue and Should-BeFalse are strict checks that only accept exactly $true or $false. Should-BeTruthy and Should-BeFalsy preserve the classic v5 behavior, accepting values like 1, 'x', 0, '', $null, and empty arrays.

Does Pester v6 still support the classic Should -Be syntax?

Yes, both syntaxes work side by side in Pester v6, so migration is optional and incremental. Once fully migrated, you can set $config.Should.DisableV5 = $true to make any remaining classic assertions throw an error.

Why does Should-Be fail when comparing arrays in Pester v6?

The new Should-Be is a value assertion and errors when -Expected is a collection. Use Should-BeCollection for array equality, Should-ContainCollection for membership checks, and Should-BeCollection -Count for count assertions.

Which Pester v5 assertions have no v6 Should-* equivalent?

Should -Exist and the Should -FileContentMatch family have no new counterpart. Either keep the classic syntax or rewrite with PowerShell, for example Test-Path $p | Should-BeTrue or (Get-Content $p -Raw) | Should-MatchString 're'.