본문으로 건너뛰기
Skillpedia
테스트40k · #7319

pester-should-migration

하는 일

이 도구는 Pester 언어로 작성된 코드 테스트를 업데이트하도록 돕습니다. 오래된 작성 방식(`Should -Be`)을 새 방식(`Should-Be`)으로 바꿔, 오류 메시지를 더 명확하게 만듭니다.

사용하는 경우

  • ✓테스트를 최신 Pester 버전에 맞게 현대화하고 싶을 때.
  • ✓오래된 테스트를 새 형식으로 바꿔야 할 때.
  • ✓더 자세하고 정확한 오류 메시지를 원할 때.

스킬 링크

https://github.com/github/awesome-copilot/blob/main/skills/pester-should-migration/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/pester-should-migration/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 코드에 있는 `Should -Be` 테스트를 `Should-Be`로 바꿔 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 `Should -Be`나 `Should -Not -Be` 같은 오래된 패턴을 찾아, 새로운 `Should-Be`나 `Should-NotBe`로 바꿉니다. 일부 변환은 테스트 동작이 그대로 유지되도록 추가 주의가 필요합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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.

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):

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.

…

자주 묻는 질문

모든 테스트를 한 번에 업데이트해야 하나요?

아니요. 테스트 하나나 파일 하나씩 업데이트할 수 있습니다. Pester는 새 버전에서도 예전 형식을 이해하므로 서두를 필요가 없습니다.

업데이트하지 않으면 어떻게 되나요?

바로 깨지는 것은 없습니다. 오래된 테스트는 Pester 6에서도 계속 작동합니다. 업데이트는 새 기능을 활용하기 위한 선택 사항입니다.

업데이트 후 일부 테스트가 작동하지 않을 수 있나요?

네, `Should -BeNullOrEmpty`나 컬렉션 비교처럼 더 복잡한 변환은 수동 조정이 필요할 수 있습니다. 변환 후에는 테스트를 확인하는 것이 중요합니다.

상세 정보

작성자의 원본 설명

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 Sh

repo: github/awesome-copilot

인기도

GitHub 스타
40k
순위
#7319
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬