Repository navigation
Conversation
The skill says what to change for each major jump. It does not say how to know you changed it correctly, and that is where a Pester 4 to 5 migration goes wrong quietly: a suite can lose most of its tests to the Discovery/Run split and stay green. One repository went from 413 tests to 138 and reported success both times. references/verifying-a-migration.md covers the parts that only show up in the field: - the baseline is a list of test names, not a pass/fail count, and it lives in its own checkout - compare the two runs test by test and report tests only in the old run, tests only in the new run, and changed results, because matching totals prove nothing - convert the CI gate along with the invocation, because FailedCount stays at 0 when a test file does not parse and when an AfterAll throws - the Discovery pass runs what you wrote, so a Describe level Mock has not applied while a Context body executes and the real command runs - moving a mock's scope can stop it intercepting, with no error saying so - symptoms that are hard to connect to their cause, including $null -contains $null being true, foreach over $null running zero times where a pipeline runs once, and InModuleScope needing the module during Discovery SKILL.md gains the reference, two stronger workflow steps and two safety rules. v4-to-v5.md gains a pointer from Fix 4 and three checklist lines. Everything in the new file was measured while migrating eleven public repositories in December 2026. No frontmatter changed, so the generated README tables are unaffected. 🤖
🔒 PR Risk Scan ResultsScanned 3 changed file(s).
✅ No matching risk patterns were detected in changed files.
|
🚦 Submission status: 🛠️ Requires submitter fixesRisk tier: Why this tier
Automated checks
Action needed
Review
Commands
Updated for |
🔍 Vally Lint Results✅ All checks passed
Summary
Full linter output |
There was a problem hiding this comment.
🟡 Changes recommended
The verification guidance can let failed Pester runs exit successfully, while duplicate-key overwrites and inconsistent hierarchy encoding make test comparisons unreliable.
3 open issues
What changed in this PR
Strengthens the pester-migration skill with verification guidance to detect silent test loss and migration regressions.
Changes:
- Adds baseline capture and test-by-test comparison examples.
- Documents CI failure checks and Discovery-time mock hazards.
- Updates the migration workflow and v4→v5 checklist.
| File | Description |
|---|---|
skills/pester-migration/SKILL.md |
Links the reference and strengthens verification and safety steps. |
skills/pester-migration/references/verifying-a-migration.md |
Adds comparison scripts, CI guidance, and migration pitfalls. |
skills/pester-migration/references/v4-to-v5.md |
Adds a Discovery warning and verification checklist items. |
Review effort: Balanced (adaptive)
|
|
||
| ```powershell | ||
| if ('Passed' -ne $result.Result) { | ||
| Write-Error "Pester run result was '$($result.Result)', with $($result.FailedCount) failed tests." |
| $chain = @($test.Describe, $test.Context, $test.Name) | Where-Object { $_ } | ||
| [pscustomobject]@{ Path = ($chain -join ' > '); Result = $test.Result } |
| $before = @{}; Import-Csv .\before.csv | ForEach-Object { $before[$_.Path] = $_.Result } | ||
| $after = @{}; Import-Csv .\after.csv | ForEach-Object { $after[$_.Path] = $_.Result } |


The
pester-migrationskill says what to change for each major jump. It does not say how to knowyou changed it correctly, and on the v4 to v5 jump that is where things go wrong quietly.
The gap
A suite can lose most of its tests to the Discovery/Run split and still report success. Two
repositories, the same root cause, opposite symptoms:
The first suite built its
-TestCasesdata inBeforeAll, so during Discovery the data was emptyand three quarters of the tests were never created. Nothing failed and nothing warned.
The skill's workflow currently says "record pass/fail" for the baseline and "re-run until the result
matches the baseline" at the end. Both of those are satisfied by the green run above.
What this adds
references/verifying-a-migration.md, a new reference loaded for any jump:the baseline is one row per test name and result, captured from a second pristine checkout, with a
script that works on v4 and on v5+;
the comparison reports three numbers, tests only in the old run, tests only in the new run, and
tests in both whose result changed, with the two cases that legitimately appear in the first column;
convert the CI gate along with the invocation. Measured on 5.3.3, 5.9.1 and 6.2.0:
ResultFailedCountif ($r.FailedCount -gt 0)fire?FailedAfterAllthat throwsFailedBeforeAllthat throwsFailed-Skip+Set-ItResult -InconclusivePassedthe Discovery pass runs what you wrote, so a
DescribelevelMockhas not applied while aContextbody executes and the real command runs:moving a mock's scope can stop it intercepting, with no error saying so;
a table of symptoms that are hard to connect to their cause:
$null -contains $nullbeing$true(one 41 line file produced 24,000 failures through it),
foreach ($x in $null)running zero timeswhere a pipeline runs once,
InModuleScopeneeding the module during Discovery, a statementbetween two
Describeblocks being teardown rather than setup, and markup in a test name;two things that do work and are worth knowing, including that
BeforeAll { Set-StrictMode -Version Latest }reaches the test bodies;that asking which Pester is installed with
Get-Command New-PesterConfigurationloads the newestone next to the version the script imported on purpose.
SKILL.mdgains the reference row, a stronger baseline step, a "compare by name" step and two safetyrules.
v4-to-v5.mdgains a pointer from Fix 4 and three checklist lines.Where the content comes from
All of it was measured while migrating eleven public PowerShell repositories from Pester 4 to Pester 6
during December 2026, including Crescendo, PScribo, OutSystems.SetupTools, PSSlack and d365fo.tools.
Where a number appears in the new file, it came from a run.
The
FailedCountgate was wrong in seven of the eleven, including a repository maintained by thePester project itself and one whose migration two other people had done carefully from the release
notes. Nothing about
FailedCountlooks wrong, and no error message mentions it, which is why itbelongs in the skill rather than in a blog post.
Not changed
No frontmatter, so the generated README tables are unaffected and
npm run buildproduces no diff.The
pester-should-migrationskill needs nothing: itsassertion-map.mdalready covers the strictShould-BeTrue/Should-BeTruthysplit, theShould -BeNullOrEmptyfan-out andShould-Beerroringon a collection, which were the three things I had measured there.
🤖