pester-should-migration
Fungsinya
Tool ini membantu memperbarui kode tes Anda yang ditulis dengan Pester. Tool ini mengubah cara penulisan tes yang lama (`Should -Be`) menjadi cara yang baru (`Should-Be`), sehingga pesan error menjadi lebih jelas.
Kapan dipakai
- โSaat Anda ingin memodernisasi tes ke versi Pester terbaru.
- โSaat Anda perlu mengubah tes lama ke format baru.
- โSaat Anda ingin pesan error yang lebih detail dan presisi.
Link skill
https://github.com/github/awesome-copilot/blob/main/skills/pester-should-migration/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
โUbah tes `Should -Be` menjadi `Should-Be` di kode saya.โ
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Tool ini mencari pola lama seperti `Should -Be` atau `Should -Not -Be`, lalu menggantinya dengan `Should-Be` atau `Should-NotBe` yang baru. Beberapa konversi memerlukan perhatian ekstra agar perilaku tes tetap sama.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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 -Bestyle 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 classicShould -Bekeeps working, so adoptingShould-*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
-Notswitch:Should -Not -BeโShould-NotBe. There is no-Notparameter 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).-Becausecarries 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:
- Case sensitivity. Classic
Should -Beis case-insensitive on strings; so isShould-Be. But classicShould -BeExactly(case-sensitive) has no plain equivalent โ useShould-BeString -CaseSensitive. (Should-Beis never case-sensitive.) Same pattern forBeLikeExactlyโShould-BeLikeString -CaseSensitiveandMatchExactlyโShould-MatchString -CaseSensitive. - Truthy vs. true. Classic
Should -BeTrue/-BeFalseaccept any truthy / falsy value (1,'x',0,'',$null,@()). The newShould-BeTrue/Should-BeFalseare strict (exactly$true/$false). To preserve the old loose behavior useShould-BeTruthy/Should-BeFalsy. Only use the strict ones when the value really is a boolean. BeNullOrEmptyhas no single equivalent. Pick by intent:$nullโShould-BeNull; empty string โShould-BeEmptyString; empty collection โShould-BeCollection -Count 0; broad "falsy" โShould-BeFalsy. The negationShould -Not -BeNullOrEmptysimilarly splits intoShould-NotBeNull/Should-NotBeEmptyString/Should-NotBeWhiteSpaceString.
โฆ
Pertanyaan umum
Apakah saya perlu memperbarui semua tes sekaligus?
Tidak. Anda bisa memperbarui satu tes atau satu file dalam satu waktu. Pester masih memahami format lama di versi baru, jadi tidak perlu terburu-buru.
Apa yang terjadi jika saya tidak memperbarui?
Tidak ada yang langsung rusak. Tes lama akan tetap berjalan di Pester versi 6. Memperbarui bersifat opsional agar Anda bisa memanfaatkan fitur baru.
Apakah ada tes yang bisa berhenti berfungsi setelah diperbarui?
Ya. Beberapa konversi lebih kompleks, seperti `Should -BeNullOrEmpty` atau perbandingan koleksi, dan mungkin memerlukan penyesuaian manual agar tes berjalan sesuai harapan. Penting untuk memeriksa ulang tes setelah konversi.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 40k
- Peringkat
- #7319
- Lisensi
- MIT
- Diperbarui
- 15/10/2026
Komentar
- โฆ
Skill lain dari repositori ini
acquire-codebase-knowledge
40kMembantu agent Anda memahami dan mendokumentasikan proyek kode yang sudah ada. Berguna untuk proses onboarding anggota baru atau mendapatkan gambaran arsitektur.
acreadiness-assess
40kMemungkinkan agent Anda menilai kesiapan proyek untuk AI dan membuat laporannya. Berguna untuk mengetahui seberapa siap proyek menggunakan alat AI.
acreadiness-generate-instructions
40kMembantu agent Anda membuat instruksi untuk alat AI berdasarkan hasil penilaian. Berguna untuk meningkatkan cara AI berinteraksi dengan kode dan menutup celah yang ditemukan.
acreadiness-policy
40kMemungkinkan agent Anda membantu menyusun atau menerapkan kebijakan untuk penilaian proyek AI. Berguna untuk menstandarisasi evaluasi proyek dan memastikan kepatuhan.
Skill serupa
test-driven-development
311kMengajari agent Anda menulis tes yang gagal dulu, melihatnya gagal, lalu menulis kode terkecil yang lulus, sebelum membangun fitur atau perbaikan apa pun.
verification-before-completion
311kMengajari agent Anda menjalankan pemeriksaan nyata dan membaca keluarannya sebelum menyatakan tugas, perbaikan, atau build sudah selesai atau lulus.
migrate-to-shoehorn
310kMengganti type cast berisiko di file tes Anda dengan pustaka shoehorn, sehingga tes bisa memakai data parsial dan tetap lulus pemeriksaan tipe.