pester-migration
Fungsinya
Tool ini membantu memperbarui tes perangkat lunak Anda (disebut Pester) untuk versi PowerShell yang lebih baru. Tool ini menyesuaikan cara tes ditulis dan dijalankan agar tetap berfungsi dengan benar pada versi baru.
Kapan dipakai
- βSaat Anda memperbarui lingkungan pengembangan ke versi PowerShell major yang baru.
- βSaat tes Pester lama Anda berhenti berfungsi setelah pembaruan.
- βUntuk memastikan tes perangkat lunak Anda selaras dengan versi tool terbaru.
Link skill
https://github.com/github/awesome-copilot/blob/main/skills/pester-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
βPerbarui tes Pester saya dari versi 4 ke versi 5.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Tool ini menganalisis tes yang sudah ada dan menerapkan perubahan yang diperlukan pada sintaks dan struktur. Tool ini mengikuti panduan khusus untuk setiap pembaruan versi, sehingga perubahan dilakukan dengan benar.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Pester Migration
Pester is the test framework for PowerShell. Test files end in *.Tests.ps1 and use
Describe / Context / It blocks with Should assertions. This skill upgrades an existing
suite from one major Pester version to the next and gets it green again.
Mental model: each major jump has a different character. v3βv4 is mostly a syntax rename. v4βv5 is a fundamental runtime change (the Discovery/Run split) and is the hard one. v5βv6 is largely backwards-compatible β a handful of previously-deprecated things now throw. Migrate one major at a time; never skip a version.
Detailed, symptom-driven guides live in references/ β load the one(s) for the jump you are doing.
References
| Reference | When to load |
|---|---|
| v3-to-v4.md | Should Be β Should -Be, Contain β FileContentMatch, Assert-VerifiableMocks β Assert-VerifiableMock, array-assertion edge cases. |
| v4-to-v5.md | The big one. Discovery/Run phases, BeforeAll setup, $PSScriptRoot, BeforeDiscovery, -ForEach, mock scoping, Should -Throw wildcards, Invoke-Pester β New-PesterConfiguration. |
| v5-to-v6.md | PowerShell 5.1/7.4+ only, per-file discovery+run, empty -ForEach throws, duplicate setup blocks throw, name <...> templates evaluate, Assert-MockCalled removed, mocks no longer fall through, code-coverage tracer, legacy Invoke-Pester params removed. |
Canonical source: the official migration guides at https://pester.dev/docs/migrations/ β this skill mirrors them. When in doubt, prefer the website.
Step 0 β Detect where you are and where you're going
Find the installed version(s) and the version the tests were written for. These can differ.
# Installed Pester version(s) on this machine
Get-Module Pester -ListAvailable | Select-Object Name, Version, Path
# Version currently imported in the session
(Get-Module Pester).Version
Tell the source version from the test code with these heuristics:
You see in *.Tests.ps1 / build scripts |
Suite was written for |
|---|---|
Should Be / Should Contain (no dash) |
v3 or earlier β start at v3-to-v4 |
$MyInvocation.MyCommand.Path + dot-source at the top of the file; arbitrary code directly under Describe |
v4 β v4-to-v5 |
Assert-MockCalled, Assert-VerifiableMock, Set-ItResult -Pending |
v4 / early-v5 (these are removed in v6) |
Invoke-Pester -Script β¦ -OutputFile β¦ -CodeCoverage β¦ (legacy params) |
v4 invocation β map to config |
BeforeAll { . $PSScriptRoot/β¦ }, New-PesterConfiguration, Should -Invoke |
already v5-style β v5-to-v6 |
Install the target version when ready:
# Latest stable v5 β pin the major to avoid installing Pester 6
Install-Module Pester -MaximumVersion 5.99.99 -Force
# Pester 6
Install-Module Pester -Force
On Windows PowerShell 5.1 the OS ships a Microsoft-signed built-in Pester 3 that PowerShellGet won't overwrite with the differently-signed newer Pester β add
-SkipPublisherCheckthere to install side-by-side. Not needed on PowerShell 7+. See https://pester.dev/docs/introduction/installation.
Migration workflow
Run this loop for each major jump. Do not jump two majors at once β go v4βv5, then v5βv6.
- Baseline. Run the suite on the current version first and record pass/fail. You need a
known-good (or known) starting point so you can tell migration regressions apart from
pre-existing failures.
# Bare Invoke-Pester works on every major; exact parameters differ # (v3/v4: -Script/-OutputFile; v5+/v6: -Path/-Output). Invoke-Pester - Read the reference for this jump (table above) so you know the full scope before editing.
- Edit file by file. Apply the mechanical changes (see per-jump cheat sheets below and in the reference). Keep changes small and reviewable β one file or one concern at a time.
- Switch versions with
Install-Module(Step 0), then re-import:Remove-Module Pester; Import-Module Pester(or start a fresh session). - Run and fix. Re-run with
-Output Detailed; use-Output Diagnostic(v4βv5) or read the explicit v6 error messages to locate problems. Match each failure to the symptom β fix tables in the reference.
β¦
Pertanyaan umum
Apa itu Pester?
Pester adalah framework untuk menulis tes otomatis bagi kode yang ditulis dengan PowerShell. Pester membantu memastikan kode Anda berjalan sesuai harapan.
Kenapa saya perlu memperbarui tes Pester?
Seperti perangkat lunak lainnya, Pester terus berkembang. Versi baru dapat membawa perubahan yang membuat tes yang ditulis untuk versi lama tidak kompatibel. Dengan memperbarui, tes Anda tetap berfungsi dan bisa memanfaatkan fitur baru.
Bisakah saya melewati beberapa versi saat memperbarui?
Tidak disarankan. Sebaiknya perbarui satu versi major dalam satu waktu (misalnya dari v3 ke v4, lalu v4 ke v5) agar perubahannya lebih mudah dikelola dan kesalahan yang rumit bisa dihindari.
Detail
Deskripsi asli dari pembuat
Pester migration skill for upgrading PowerShell Pester test suites across major versions β v3βv4, v4βv5, and v5βv6. Covers the Discovery/Run two-phase model, moving setup into BeforeAll, $PSScriptRoot vs $MyInvocation, mock changes (Assert-MockCalled β Should -Invoke, removed fall-through), Invoke-Pester parameters β PesterConfiguration, data-driven -ForEach/-TestCases, and the v6 breaking changes
repo: github/awesome-copilot
Popularitas
- Bintang GitHub
- 40k
- Peringkat
- #7318
- 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.