Closed jackmtpt closed 3 months ago
In Pester v4 that might have worked but in Pester v5 it is not a wildcard by default. It works now by adding *
.
Describe 'Something' {
It 'Should throw' {
{ throw 'foo bar baz' } | Should -Throw '*bar*'
}
}
Not sure if new behavior is document somewhere in the v5 documentation. But it is mentioned here in breaking changes: https://github.com/pester/Pester/releases/tag/5.0.0
yeah i realised that after i posted this issue. i'd delete it but apparently i can't.
No need to delete, it is good knowledge for others that hit the same issue. I think it could also been kept open so it could be tracked to get the documentation updated. 🙂
https://pester.dev/docs/assertions/#throw the docs were updated, I just can't google good 😆
I just can't google good 😆
Or... ideally v5 docs should rank higher. If anyone knows a SEO trick, let us know :)
Checklist
What is the issue?
The documentation (https://pester.dev/docs/v4/usage/assertions#throw) says that the following code should work:
{throw "foo bar baz"} | Should -Throw "bar" # Test will pass
It does not; the assertion fails.
Expected Behavior
The test should pass, instead, the following error is generated:
Steps To Reproduce
Describe your environment
Pester 5.6.1, Win11, pwsh 7.4.4
Possible Solution?
No response