|
We are migrating a Pester test suite from Pester 5.7.1 to Pester 6. Our tests compare the complete content of large generated files. The files can contain 10,000 and more lines. In Pester 5, we currently use: $expected = Get-Content -LiteralPath $expectedPath -Raw
Get-Content -LiteralPath $actualPath -Raw | Should -BeExactly $expectedWhen this fails, For the Pester 6 assertion syntax we tried: $actual = Get-Content -LiteralPath $actualPath -Raw
$expected = Get-Content -LiteralPath $expectedPath -Raw
$actual | Should-BeString -Expected $expected -CaseSensitiveWhat is the recommended Pester 6 assertion, switch, or configuration setting to get the same diagnostic behavior as classic If this behavior is not currently available, would it be reasonable to add it to Sidenote: TestDrive is not working for me, it expands to C: Complete Pester File: Describe 'Vergleich klassisch vs. neu' {
BeforeAll {
$actualPath = "TestDrive:\actual.txt"
$expectedPath = "TestDrive:\expected.txt"
$actualLines = 1..10000 | ForEach-Object {
"Line {0:D5}" -f $_
}
$expectedLines = [string[]]$actualLines.Clone()
$expectedLines[5432] = "Line 99999" # Change one line to make the test fail
Set-Content -LiteralPath $actualPath -Value $actualLines
Set-Content -LiteralPath $expectedPath -Value $expectedLines
}
It 'V5 Syntax: BeExactly' {
$expected = Get-Content $expectedPath -Raw
Get-Content $actualPath -Raw | Should -BeExactly $expected
}
It 'V6 Syntax: Should-BeString' {
$actual = Get-Content $actualPath -Raw
$expected = Get-Content $expectedPath -Raw
$actual | Should-BeString $expected
}
}Collapsed Output (Cuttet / too long for GitHub)Pester v6.1.0-alpha2Running tests from 1 files. Running tests from 'C:\Code\Pester-BeExactlyV6.Tests.ps1' |
Thanks for the detailed report 🙂 AFAIK
$actual | Should-BeString -Expected $expected -CaseSensitiveshould work as you'd expect, so let's track this as a bug/missed feature in #2951