Breaking changes in v5
Actual breaking changes​
-
The Parameters of
Invoke-Pesterchanged significantly, but in 5.0.1, a compatibility parameter set was added. To allow all the v4 parameters to be used, e.g. like thisInvoke-Pester -Script $testFile -PassThru -Verbose -OutputFile $tr -OutputFormat NUnitXml -CodeCoverage "$tmp/*-*.ps1" -CodeCoverageOutputFile $cc -Show All. The compatibility is not 100%, neither -Script not -CodeCoverage take hashtables, they just take a collection of paths. The-Strictparameter and-PesterOptionare ignored. The-Output\-Showparameter takes all the values, but translates only the most used options to Pester 5 compatible options, otherwise it usesDetailedoutput. It also allows all the Pester 5 output options, to allow you to useDiagnosticduring migration. This whole Legacy-parameter set is deprecated and prints a warning when used. For more options and the Advanced interface see simple and advanced interface above on how to invoke Pester. -
PowerShell 2 is no longer supported
-
Legacy syntax
Should Be(without-) is removed, see Migrating from Pester v3 to v4 -
Mocks are scoped based on their placement, not in whole
Describe/Context. The count also depends on their placement. See mock scoping -
Assert-VerifiableMockswas removed, see Should -Invoke -
All code placed in the body of
Describeoutside ofIt,BeforeAll,BeforeEach,AfterAll,AfterEachwill run during discovery and it's state might or might not be available to the test code, see Discovery and Run -
-Outputparameter has reduced options toNone,Normal,DetailedandDiagnostic,-Showalias is removed -
-PesterOptionswitch is removed -
-TestNameswitch is replaced with-FullNameFilterswitch -
-Scriptoption was renamed to-Pathand takes paths only, it does not take hashtables. For parametrized scripts, see Providing external data to tests -
Using
$MyInvocation.MyCommand.Pathto locate your script inBeforeAlldoes not work. This does not break it for your scripts and modules. Use$PSScriptRootor$PSCommandPath. See Migrating from Pester v4 or the importing ps files article for detailed information. -
Should
-Throwis using-liketo match the exception message instead of .Contains. Use*or any of the other-likewildcard to match only part of the message. -
Variables defined during Discovery, are not available in Before*, After* and It. When generating tests via foreach blocks, make sure you pass all variables into the test using -TestCases / -ForEach.
-
Gherkin is removed, and will later move to it's own module, please keep using Pester version 4.
-
TestDriveis defined during Run only, it cannot be used in -TestCases / -ForEach.
Deprecated features​
Assert-MockCalledis deprecated, it is recommended to use Should -InvokeAssert-VerifiableMockis deprecated, it is recommended to use Should -InvokeVerifiable
Additional issues to be solved future releases​
-Strictswitch is not available- Inconclusive and Pending states are currently no longer available,
-Pendingand-Inconclusiveare translated to-Skipboth on test blocks and when usingSet-ItResult - Automatic Code coverage via -CI switch currently disabled as it's slow. Can still be enabled using configuration, but is largely untested.
- Generating tests using foreach during discovery time works mostly, generating them from BeforeAll, to postpone expensive work till it is needed in case the test is filtered out also works, but is hacky. Get in touch if you need it and help me refine it.
- Running on huge codebases is largely untested
Noticed more of them? Share please!