Breaking changes in v5
Actual breaking changes​
- The Parameters of
Invoke-Pester
changed significantly, but 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
. Be aware of these limitations and notes:- The compatibility is not 100%, neither
-Script
not-CodeCoverage
take hashtables, they just take a collection of paths. - The
-Strict
parameter and-PesterOption
are ignored. - The
-Output
\-Show
parameter takes all the values, but translates only the most used options to Pester 5 compatible options, otherwise it usesDetailed
output. It also allows all the Pester 5 output options, to allow you to useDiagnostic
during 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.
- The compatibility is not 100%, neither
- 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-VerifiableMocks
was removed, see Should -Invoke- All code placed in the body of
Describe
outside ofIt
,BeforeAll
,BeforeEach
,AfterAll
,AfterEach
will run during discovery and it's state might or might not be available to the test code, see Discovery and Run -Output
parameter has reduced options toNone
,Normal
,Detailed
andDiagnostic
.-Show
alias is removed-PesterOption
switch is removed-TestName
switch is replaced with-FullNameFilter
switch-Script
option was renamed to-Path
and takes paths only, it does not take hashtables. For parametrized scripts, see Providing external data to tests- Using
$MyInvocation.MyCommand.Path
to locate your script inBeforeAll
does not work. This does not break it for your scripts and modules. Use$PSScriptRoot
or$PSCommandPath
. See Migrating from Pester v4 or the importing ps files article for detailed information. - Should
-Throw
is using-like
to match the exception message instead of .Contains. Use*
or any of the other-like
wildcard to match only part of the message. - Variables defined during Discovery, are not available in
BeforeAll/-Each
,AfterAll/-Each
andIt
. When generating tests via foreach blocks, make sure you pass all variables into the test using-ForEach
. - Gherkin is removed, please keep using Pester version 4.
TestDrive
is defined during Run only, it cannot be used in-ForEach
.
Deprecated features​
Assert-MockCalled
is deprecated, it is recommended to use Should -Invoke.Assert-VerifiableMock
is deprecated, it is recommended to use Should -InvokeVerifiable.- Pending state (
Set-ItResult -Pending
) is deprecated and will be removed in a future version.
Additional issues to be solved future releases​
-Strict
switch is not available- Automatic Code coverage via -CI switch currently disabled as it's slow. Can still be enabled using configuraitonis largely untested.
Noticed more of them? Share please!