Checklist
What is the issue?
In PowerShell 7.1+ the string difference error from Should-BeString, Should -Be/BeExactly is broken using the default ErrorView (ConciseView)
Expected Behavior
A clean and readable error message
Steps To Reproduce
# Same error with 'abc' | Should -Be 'Two' etc.
PS /workspaces/Pester> 'abc' | Should-BeString 'ab'
InvalidResult:
Line |
1 | 'abc' | Should-BeString 'ab'
| Expected strings to be the same, but they were different. Expected length: 2 Actual length: 3 Strings differ at index 2. Expected: 'ab' But was: 'abc'
| --^
# Expected
PS /workspaces/Pester> $ErrorView = 'NormalView'
PS /workspaces/Pester> 'abc' | Should-BeString 'ab'
Expected strings to be the same, but they were different.
Expected length: 2
Actual length: 3
Strings differ at index 2.
Expected: 'ab'
But was: 'abc'
--^
At /workspaces/Pester/src/functions/assert/Common/Invoke-AssertionFailed.ps1:58 char:9
+ throw $errorRecord
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (System.Collections.…ring,System.Object]:Dictionary`2) [], Exception
+ FullyQualifiedErrorId : PesterAssertionFailed
Describe your environment
Pester version : 6.1.0-alpha2 /workspaces/Pester/bin/Pester.psm1
PowerShell version : 7.6.2
OS version : Unix 6.18.35.2
Possible Solution?
ConciseView trims newlines, so maybe fallback to simple Should-Be error like Expected [string] 'ab', but got [string] 'abc'.?
Override $ErrorView to NormalView if ConciseView?
Checklist
What is the issue?
In PowerShell 7.1+ the string difference error from
Should-BeString,Should -Be/BeExactlyis broken using the default ErrorView (ConciseView)Expected Behavior
A clean and readable error message
Steps To Reproduce
Describe your environment
Pester version : 6.1.0-alpha2 /workspaces/Pester/bin/Pester.psm1
PowerShell version : 7.6.2
OS version : Unix 6.18.35.2
Possible Solution?
ConciseView trims newlines, so maybe fallback to simple
Should-Beerror likeExpected [string] 'ab', but got [string] 'abc'.?Override
$ErrorViewtoNormalViewifConciseView?