Thumbnail: pester

Get-ShouldOperator

by on under blog
1 minute read

How do I discover Should operators?

If you’ve ever tried to learn Pester, PowerShell’s foremost code testing framework, you probably recognize this question.

Hopefully, you found the answers you needed on the Pester wiki, but that’s not an ideal solution. The wiki is not updated with the same frequency as the project, and we want quick answers via our PowerShell console, not on the website.

Enter Hacktoberfest. (And associated nice swag.)

hacktoberfest2018

After submitting some small PRs on other projects, I went hunting for a “good first issue” on the Pester repository, and decided I was most interested in solving this problem.

Soon, a pull request was born. After some discussion and tweaks, and subsequent testing and acceptance by (super deserving Microsoft MVP) Jakub, Get-ShouldOperator makes its debut in Pester’s brand new 4.5.0 release.

The use case is simple: Get-ShouldOperator returns every assertion operator available to Pester. By default, the displayed operators ship with Pester, but you would also see any custom registrations you may have added with Add-AssertionOperator.

getshouldoperator1

Let’s say “Contain” sounds like what you’re looking for. You can quickly get a synopsis of what it does, and view the example(s) pulled from the Pester wiki:

getshouldoperator2

4.5.0 is available on the PowerShell Gallery. Run your Install-Module Pester/Update-Module Pester commands today, and start using Get-ShouldOperator to help you get quicker answers!

powershell, pester, hacktoberfest