Skip to main content
skill GitHub Copilot official · GitHub

pester-should-migration — GitHub Copilot skill: setup & use

Converts classic Pester v5 Should -Be assertions to the Pester v6 Should-Be syntax without spaces. Designed for modernizing PowerShell test suites.

Install into GitHub Copilot · Skills CLI (Vercel) All methods and platforms ↓
npx skills add github/awesome-copilot --skill pester-should-migration
Open on GitHub

What pester-should-migration does

This skill scans *.Tests.ps1 files for classic space-separated syntax like Should -Be and Assert-MockCalled. It converts them to Pester v6 hyphenated assertions such as Should-Be and Should-Invoke. Negation turns into standalone commands like Should-NotBe because the new syntax drops the -Not parameter.

Behavioral differences require careful conversion rather than blind string replacement. Should-BeTrue enforces strict boolean types in v6, so truthy checks require Should-BeTruthy. Passing collections into -Expected with Should-Be causes errors, demanding Should-BeCollection instead. Commands like Should -Exist lack direct v6 equivalents and require PowerShell commands like Test-Path.

The guidance targets Pester 6.0.0-rc2 and requires Pester v6+. You should install this skill when adopting v6 assertions, while runtime and config upgrades across major versions belong in the companion pester-migration skill.

What it helps with

  • convert classic Should -Be assertions to Pester v6 Should-Be syntax
  • replace Should -Not -Be calls with dedicated Should-NotBe commands
  • switch array comparisons to Should-BeCollection to prevent errors
  • split Should -BeNullOrEmpty into type-specific null and empty string checks

Example prompts for the agent

  • Migrate all Should -... calls in tests/User.Tests.ps1 to Pester v6 assertions
  • Convert classic assertions in this test folder to Should-*
  • Update Should -Be and Should -Contain calls in my PowerShell tests

How to install pester-should-migration

1Skills CLI (Vercel)

npx skills add github/awesome-copilot --skill pester-should-migration

2GitHub CLI

gh skill install github/awesome-copilot pester-should-migration

3Manually: put the files in place

.github/skills/pester-should-migration/SKILL.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

ios-ettrace-performance official OpenAI A Codex skill for capturing symbolicated ETTrace profiles in the iOS Simulator. It helps pinpoint launch latency and CPU-heavy call stacks for a specific flow. CX Codex GP ChatGPT 87installs application-integration-authoring official google Manage Google Cloud Application Integration versions through the REST API or Python client. Use it to publish workflows and promote versions across environments. Claude Code Gemini CLI CX Codex 16installs agent-harness Alireza Rezvani Turns a goal into tasks with machine-run checks, then keeps the loop open until each task is verified or explicitly waived. Use it for work that needs a verifiable close. Claude Code 68installs game-playtest official OpenAI Guides agents through browser game playtests and frontend QA. It focuses on boot checks, controls, HUD overlay balance, and visual regression capture. CX Codex GP ChatGPT 62installs build-run-debug official OpenAI Build, launch, and debug macOS apps through a shell-first Xcode and Swift workflow when startup or runtime failures need investigation. CX Codex GP ChatGPT 60installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs design-taste-frontend Leonxlnx This skill directs the design of public pages and work screens, then checks the result in a browser through screenshots. Use it when an interface feels generic or unfinished. Claude Code CX Codex Cursor +1 673,100installs tdd Matt Pocock Guides the red-green TDD loop: ensures tests are written first, keep them at public interfaces, and avoid coupling to implementation details. Claude Code 1,141,062installs

Questions about pester-should-migration

How to install pester-should-migration in GitHub Copilot?

Run gh skill install github/awesome-copilot pester-should-migration or install it with npx skills add github/awesome-copilot --skill pester-should-migration.

What does pester-should-migration do?

It rewrites Pester v5 assertions to the new v6 hyphenated Should-* syntax while adjusting for collection handling and strict boolean changes.

Do all classic assertions need to be converted at once?

No. Pester v6 supports both syntaxes side by side, so you can migrate tests incrementally file by file.

Source text

SKILL.md · MIT
---
name: pester-should-migration
description: 'Experimental (preview) Pester skill for migrating classic Should -Be (v5) assertion syntax to the new Should-* (v6) assertions (note the hyphen, no space), e.g. `Should -Be` -> `Should-Be`, `Should -Not -Be` -> `Should-NotBe`. Tracks Pester 6, which is still a release candidate, so this guidance may change; verified against Pester 6.0.0-rc2. Use when converting Pester v5 assertions to Pester v6 Should-* operators, modernizing a Pester test suite, or when a user asks to migrate, convert, or rewrite `Should -...` calls in .Tests.ps1 / PowerShell files.'
argument-hint: "File, folder, or test suite to migrate"
---

# Pester `Should -*` → `Should-*` Migration

Convert classic Pester v5 assertions (`Should -Be`, space then parameter) to the
new Pester v6 `Should-*` assertions (`Should-Be`, hyphen, no space).

> **Status: experimental / preview.** Verified against Pester 6.0.0-rc2. The classic
> `Should -Be` style still works in v6, so migrate incrementally and keep the suite green.

> **Companion skill.** This skill covers the *optional* move to the new `Should-*` operators.
> To upgrade a suite across major Pester versions (v3→v4→v5→v6 — the runtime, mocks, and config),
> use the separate **pester-migration** skill. In v6 the classic `Should -Be` keeps working, so
> adopting `Should-*` is independent of any version bump.

## When to Use

- Modernizing a Pester suite to the v6 `Should-*` assertions.
- A user asks to migrate / convert / rewrite `Should -...` calls.
- You want clearer, type-aware failure messages from the new assertions.

## Know This First

- **Both syntaxes work side by side in Pester v6.** Migration is optional and can
  be done one test (or one file) at a time. Nothing breaks if you leave some classic.
- **Requires Pester v6+.** The `Should-*` commands do not exist in v5.
- **Negation is a separate command**, not a `-Not` switch: `Should -Not -Be` →
  `Should-NotBe`. There is no `-Not` parameter on the new assertions.
- **The actual value still comes from the pipeline** (`$x | Should-Be 1`) or from
  `-Actual` (`Should-Be -Actual $x -Expected 1`). `-Because` carries over unchanged.
- **Most renames are mechanical**, but several have behavior changes you must check
  by hand — see [Gotchas](#step-3--check-the-behavioral-gotchas-do-not-skip).

## Procedure

### Step 1 — Find the classic assertions

Search the target for the classic space-separated syntax (the tell is `Should -`,
or `Should` followed by `-Not`):

```
Should -          # any classic operator
Should -Not -     # negated classic operator
Assert-MockCalled # also removed in v6 -> Should-Invoke
```

Limit the scope to PowerShell test files (`*.Tests.ps1`, `*.ps1`).

### Step 2 — Apply the mapping

Most-used conversions (full list in [references/assertion-map.md](references/assertion-map.md)):

| Classic (v5) | New (v6) |
|---|---|
| `$x \| Should -Be 1` | `$x \| Should-Be 1` |
| `$x \| Should -Not -Be 1` | `$x \| Should-NotBe 1` |
| `$x \| Should -BeExactly 'A'` | `$x \| Should-BeString 'A' -CaseSensitive` |
| `$x \| Should -BeGreaterOrEqual 2` | `$x \| Should-BeGreaterThanOrEqual 2` |
| `$x \| Should -BeLessOrEqual 2` | `$x \| Should-BeLessThanOrEqual 2` |
| `$x \| Should -BeLike 'a*'` | `$x \| Should-BeLikeString 'a*'` |
| `$x \| Should -Match 're'` | `$x \| Should-MatchString 're'` |
| `$x \| Should -BeOfType [int]` | `$x \| Should-HaveType ([int])` |
| `$x \| Should -BeNullOrEmpty` | depends — see gotchas (no single equivalent) |
| `$c \| Should -HaveCount 3` | `$c \| Should-BeCollection -Count 3` |
| `$c \| Should -Contain 2` | `$c \| Should-ContainCollection 2` |
| `{ ... } \| Should -Throw 'msg'` | `{ ... } \| Should-Throw -ExceptionMessage 'msg'` |
| `Should -Invoke Get-Thing` | `Should-Invoke Get-Thing` |
| `Should -InvokeVerifiable` | `Should-Invoke -Verifiable` |

### Step 3 — Check the behavioral gotchas (do NOT skip)

These do **not** translate by a plain rename. Read each before converting:

1. **Case sensitivity.** Classic `Should -Be` is case-insensitive on strings; so is
   `Should-Be`. But classic `Should -BeExactly` (case-sensitive) has **no** plain
   equivalent — use `Should-BeString -CaseSensitive`. (`Should-Be` is never
   case-sensitive.) Same pattern for `BeLikeExactly` → `Should-BeLikeString -CaseSensitive`
   and `MatchExactly` → `Should-MatchString -CaseSensitive`.
2. **Truthy vs. true.** Classic `Should -BeTrue` / `-BeFalse` accept any *truthy* /
   *falsy* value (`1`, `'x'`, `0`, `''`, `$null`, `@()`). The new `Should-BeTrue` /
   `Should-BeFalse` are **strict** (exactly `$true` / `$false`). To preserve the old
   loose behavior use `Should-BeTruthy` / `Should-BeFalsy`. Only use the strict ones
   when the value really is a boolean.
3. **`BeNullOrEmpty` has no single equivalent.** Pick by intent: `$null` →
   `Should-BeNull`; empty string → `Should-BeEmptyString`; empty collection →
   `Should-BeCollection -Count 0`; broad "falsy" → `Should-BeFalsy`. The negation
   `Should -Not -BeNullOrEmpty` similarly splits into `Should-NotBeNull` /
   `Should-NotBeEmptyString` / `Should-NotBeWhiteSpaceString`.
4. **Collections.** Classic `Should -Be` also compares arrays; the new `Should-Be` is
   a *value* assertion and **errors** if `-Expected` is a collection ("You provided a
   collection to the -Expected parameter"). Use `Should-BeCollection` to compare arrays.
   `Should -Contain` (single-item membership) → `Should-ContainCollection`. The new
   command also takes a **collection** of expected items and checks they are all present,
   in the right order (`1, 2, 3 | Should-ContainCollection @(1, 2)`). For exact,
   whole-collection equality use `Should-BeCollection` instead.
5. **Pipeline unwrapping.** The pipeline unwraps input: a value assertion sees `@(1)`
   as `1` and `@()` as `$null`, and a typed collection (`[int[]]`) is re-collected as
   `[object[]]`. When the exact value or concrete collection type matters (e.g.
   `Should-HaveType`), pass it with `-Actual` instead of piping.
6. **No `Should-*` equivalent.** `Should -Exist` and the `Should -FileContentMatch*`
   family have no new counterpart. Either keep the classic assertion, or rewrite with
   PowerShell: `Test-Path $p | Should-BeTrue`, `(Get-Content $p -Raw) | Should-MatchString 're'`.
7. **`Should -BeIn` direction.** No `Should-BeIn`. Reverse the operands:
   `$value | Should -BeIn $collection` → `$collection | Should-ContainCollection $value`
   (note the actual/expected swap), or keep the classic form.

### Step 4 — Verify

Run the suite and confirm it's still green — the new messages differ, but passes
must stay passes:

```powershell
Invoke-Pester -Path ./tests
```

If a converted assertion newly fails, re-check the gotchas above (most often #2
truthy/falsy, #3 null-or-empty, or #4 collections).

### Step 5 — (Optional) Enforce the new style

Once a suite is fully migrated, switch off the classic syntax so it can't creep back:

```powershell
$config = New-PesterConfiguration
$config.Should.DisableV5 = $true
```

With this set, any remaining `Should -Be` throws and points at the `Should-Be` form.

## Output

Summarize what changed: files touched, count of assertions converted, any classic
assertions intentionally left (e.g. `Should -Exist`), and any conversions that need
a human decision (truthy/falsy, null-or-empty, collection semantics).

## Reference

- [references/assertion-map.md](references/assertion-map.md) — full operator-by-operator
  table with before/after examples and workarounds.
- Live command reference: `https://pester.dev/docs/commands/Should-Be` (swap in any
  `Should-*` name) for exact parameters and examples.
- Concepts: `https://pester.dev/docs/assertions/should-command` (value vs. collection
  assertions, pipeline vs. `-Actual`).
- v5→v6 upgrade guide: `https://pester.dev/docs/migrations/v5-to-v6`.

© github · MIT · github/awesome-copilot

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor