-
-
Notifications
You must be signed in to change notification settings - Fork 478
Open
Milestone
Description
Checklist
- Issue has a meaningful titleI have searched the existing issues. See all issuesI have tested using the latest version of Pester. See Installation and update guide.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
What is the issue?
If the actual value or expected value contain escape character (for example an ANSI sequence) the message are not shown correctly.
Expected Behavior
Should show the special character like escape characters. Also ANSI sequences should not be hidden as they are part of the strings being compared.
Steps To Reproduce
Describe 'Something' {
It 'Escape in expected value should be handled correctly' {
'31;3;5m' | Should-BeString "`e[313;5m"
}
It 'Escape in actual value should be handled correctly' {
"`e31;3;5m" | Should-BeString '[31;3;5m'
}
It 'Escape in both expected and actual value should be handled correctly' {
"`e31;3;5m" | Should-BeString "`e[31;3;5m"
}
}
Outputs:
Starting discovery in 1 files.
Discovery found 11 tests in 30ms.
Running tests.
[-] Something.Escape in expected value should be handled correctly 10ms (9ms|2ms)
Expected [string] '', but got [string] '31;3;5m'.
at '31;3;5m' | Should-BeString "`e[313;5m", /Users/johlju/source/Viscalyx.Common/tests/Unit/Public/ConvertTo-AnsiSequence.tests.ps1:89
[-] Something.Escape in actual value should be handled correctly 24ms (22ms|2ms)
Expected [string] '[31;3;5m', but got [string] '1;3;5m'.
at "`e31;3;5m" | Should-BeString '[31;3;5m', /Users/johlju/source/Viscalyx.Common/tests/Unit/Public/ConvertTo-AnsiSequence.tests.ps1:93
[-] Something.Escape in both expected and actual value should be handled correctly 37ms (30ms|6ms)
Expected [string] '', but got [string] '1;3;5m'.
at "`e31;3;5m" | Should-BeString "`e[31;3;5m", /Users/johlju/source/Viscalyx.Common/tests/Unit/Public/ConvertTo-AnsiSequence.tests.ps1:97
Tests completed in 432ms
Tests Passed: 8, Failed: 3, Skipped: 0, Inconclusive: 0, NotRun: 0
Describe your environment
Pester version : 6.0.0-alpha4 /Users/johlju/source/Viscalyx.Common/output/RequiredModules/Pester/6.0.0/Pester.psm1
PowerShell version : 7.4.4
OS version : Unix 14.6.1
Possible Solution?
Maybe convert special characters in actual and expected value to their unicode equivalent?
"`0`a`b`t`f`r`n`e" `
-replace "`0", '␀' `
-replace "`a", '␇' `
-replace "`b", '␈' `
-replace "`t", '␉' `
-replace "`f", '␌' `
-replace "`r", '␍' `
-replace "`n", '␊' `
-replace "`e", '␛'
Maybe this should go into the Format-Nicely
function, so all strings are parsed? 🤔 Otherwise strings in expected and actual could also affect the output in the console (changing colors etc.)
Outputs:
␀␇␈␉␌␍␊␛
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
nohwnd commentedon Oct 3, 2024
yes that would be good, I've been using
␛
lately for ANSI terminal testing and it has been a lifesaver to have it as printable character.