Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides PowerShell Pester test suites through major upgrades (v3→v4, v4→v5, v5→v6), covering Discovery/Run changes, mocks and configuration.
73% 95%+23 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 16 of 22 without it.
3 of 3 safety checks passed
16 agent runs
This is the hard jump. v5 introduced a new runtime that splits a test run into two phases — Discovery and Run — and that changes how you must structure tests. It is not a pure find-and-replace. Read this whole file before editing a suite.
Official guide: https://pester.dev/docs/migrations/v4-to-v5 · Breaking changes: https://pester.dev/docs/migrations/breaking-changes-in-v5
A v5+ run happens in two passes:
*.Tests.ps1 file top to bottom but only to find tests.
It invokes the Describe/Context script blocks to collect the tree of Its, evaluates It
-Name strings and -TestCases/-ForEach data, and records BeforeAll/It/etc. script blocks
without running them.The two rules that make a suite v5-correct:
It, BeforeAll, BeforeEach, AfterAll, or AfterEach.Describe/Context bodies or at the top of the file —
unless it is meant to build tests, in which case it goes in BeforeDiscovery.Code that sits loose in a Describe body or at file top-level runs during Discovery, and its
results are usually not available during Run. This is the root cause of most "it worked in
v4, it's $null in v5" bugs.
BeforeAll and use $PSScriptRootThe classic v4 header dot-sources the system-under-test at file scope using
$MyInvocation.MyCommand.Path. Both the placement and that variable break in v5.
# BEFORE (v4)
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.