-
-
Notifications
You must be signed in to change notification settings - Fork 479
Open
Labels
Milestone
Description
Checklist
- Feature request has a meaningful title
- I have searched the existing issues. See all issues
- I have tested using the latest version of Pester. See Installation and update guide.
Summary of the feature request
Currently the new assertions for Pester v6 does not support regular expression matching like Should -Match or Should -MatchExactly in v5. Suggest adding a command Should-Match and Should-NotMatch, or possibly add a parameter RegularExpression to the commands Should-BeLikeString and Should-NotBeLikeString.
How should it work?
The commands Should-Match and Should-NotMatch should have the same named and positional parameters as the command Should-NotBeLikeString.
It 'Should match regular expression` {
'[value]' | Should-Match '^\[.+\]$'
}
It 'Should match regular expression` {
'Should-Match '^\[.+\]$' '[value]'
}
It 'Should match regular expression` {
'Should-Match -Expected '^\[.+\]$' -Actual '[value]' -CaseSensitive -Because 'must start and end with brackets'
}
It 'Should match regular expression` {
'Should-NotMatch -Expected '^\[.+\]$' -Actual 'value' -CaseSensitive -Because 'must not start and end with brackets'
}
If we reuse existing commands Should-BeLikeString and Should-NotBeLikeString by adding a new switch parameter.
It 'Should match regular expression` {
'[value]' | Should-BeLikeString '^\[.+\]$' -RegularExpression
}
It 'Should match regular expression` {
'Should-BeLikeString '^\[.+\]$' '[value]' -RegularExpression
}
It 'Should match regular expression` {
'Should-BeLikeString -RegularExpression -Expected '^\[.+\]$' -Actual '[value]' -CaseSensitive -Because 'must start and end with brackets'
}
It 'Should match regular expression` {
'Should-NotBeLikeString -Expected '^\[.+\]$' -Actual 'value' -CaseSensitive -Because 'must not start and end with brackets' -RegularExpression
}