pester / Pester

Pester is the ubiquitous test and mock framework for PowerShell.
https://pester.dev/
Other
3.1k stars 469 forks source link

`Should-BeFals*`/`Should-BeTru*`: The commands are missing named parameter `Expected` #2517

Closed johlju closed 3 months ago

johlju commented 3 months ago

Checklist

Summary of the feature request

Looking at the help for he commands

they are all missing the named parameter Expected which for example Should-Be and Should-BeExactly has.

Also, these commands has the positional parameter 1 set to Actual while position 2 is set to Because. That also differ from Should-Be and Should-BeExactly which has position 1 set to Expected and position 2 is set to Actual.

How should it work?

Is this meant to be this way, or is this something that should be resolved? I curious because it would simplify conversion from Pester 5 format to Pester 6 format if the commands behave the same. 🙂

fflaten commented 3 months ago

What would you use -Expected for?

The assertions match against a constant value as they're basically shortcuts for something like $var | Should-HaveType ([bool]); $var | Should-Be $true (True) and $var | Should-Be $true (Truthy).

johlju commented 3 months ago

Ah, of course. It was me that did not think that one through. Then the answer is it is meant to be that way.

I'm writing a syntax conversion module (Pester 5 syntax -> Pester 6 syntax), thats when I saw the difference from the other two commands. 🙂 Yesterday I saw a difference between Should -Throw and Should-Throw too. Will post another issue for that one when I have time, just to make sure it is meant to be (by design) or something that should be looked into.

Closing this one. Thank you for the quick response @fflaten!

fflaten commented 3 months ago

Thank you for testing it out and providing feedback! Looking forward to trying out the conversion-module 🤩