-
Notifications
You must be signed in to change notification settings - Fork 1
Pester_v5_Conversion
viscalyxbot edited this page Jul 12, 2024
·
5 revisions
Information converting Pester v5 to Pester v6.
The following commands are supported:
The operators of the command Should
are converted to the appropriate
Pester v6 command:
Should operator name | Affirm | Negate | Notes |
---|---|---|---|
Be | Should-Be |
Should-NotBe |
- |
BeExactly | Should-Be -CaseSensitive |
Should-NotBe -CaseSensitive |
- |
BeFalse | Should-BeFalse |
Should-BeTrue |
- |
BeGreaterOrEqual | Should-BeGreaterThanOrEqual |
Should-BeLessThanOrEqual |
- |
BeGreaterThan | Should-BeGreaterThan |
Should-BeLessThan |
- |
BeLessOrEqual | Should-BeLessThanOrEqual |
Should-BeGreaterThanOrEqual |
- |
BeLessThan | Should-BeLessThan |
Should-BeGreaterThan |
- |
BeLike | Should-BeLikeString |
Should-NotBeLikeString |
- |
BeLikeExactly | Should-BeLikeString -CaseSensitive |
Should-NotBeLikeString -CaseSensitive |
- |
BeNullOrEmpty | Should-BeFalsy |
Should-BeTruthy |
See 2) |
BeOfType | Should-HaveType |
Should-NotHaveType |
- |
BeTrue | Should-BeTrue |
Should-BeFalse |
- |
Contain | Should-ContainCollection |
Should-NotContainCollection |
- |
Match | Should-MatchString |
Should-NotMatchString
|
- |
MatchExactly | Should-MatchString -CaseSensitive
|
Should-NotMatchString -CaseSensitive
|
- |
Throw | Should-Throw |
$null = & (<ActualValue>) |
See 1) |
- There is not a command that
Should -Not -Throw
can be converted to. In Pester 6 theIt
-block catch any exception if one occurs, that means that a passingIt
-block affirms that the ran code did not throw an exception. The conversion will parse the actual value, normally a scriptblock passed as parameter or through the pipeline, and convert it to be executed using the call operator (&
) inside theIt
-block. Any output is passed to$null
so that no output affects the Pester test object. - There are no exact command to convert to, but
Should-BeFalsy
andShould-BeTruthy
is similar. But there might be scenarios where the commandsShould-BeNull
orShould-BeEmptyString
are better suited. But since the conversion has no way of knowing if those command are better suitable based on the AST theShould-BeFalsy
andShould-BeTruthy
are used.