Checklist
What is the issue?
I'm getting that the $result passed to Should-BeNull is not $null, but the verbose output I added to debug this do say it is not an array and it is indeed $null. 🤔 Not sure if I'm doing something wrong. I have seen this in another place as well but ignored it there, when I got it here I thought this must be an error somewhere. 🙂
The Out-Diff currently only writes Write-Information messages and returns no values.
I output verbose message to determine that it is indeed $null and not an array, still Should-BeNull thinks it is.
It 'Should output to console' {
$expected = @(
'My String that is longer than actual'
)
$actual = @(
'My string that is shorter'
)
$result = Out-Diff -ExpectedString $expected -ActualString $actual
Write-Verbose ($result -is [array]) -Verbose
Write-Verbose ($null -eq $result) -Verbose
$result | Should-BeNull
}
VERBOSE: False
VERBOSE: True
[-] Out-Diff.When output is made as informational message.Should output to console 124ms (122ms|2ms)
Expected $null, but got [Object[]] '@()'.
at $result | Should-BeNull -Debug -Verbose, /Users/johlju/source/Viscalyx.Common/tests/Unit/Public/Out-Diff.tests.ps1:94
Expected Behavior
Should pass test as the actual value is $null.
Steps To Reproduce
Running this reproduces the issue:
BeforeAll {
function Out-Something
{
param
(
)
}
}
Describe 'Out-Something' {
It 'Should not output anything' {
$result = $null
$result = Out-Something
Write-Verbose ("Result is null: {0}" -f ($null -eq $result)) -Verbose
Write-Verbose ("Result is array: {0}" -f ($result -is [array])) -Verbose
$result | Should-BeNull
}
}
Returns:
Starting discovery in 1 files.
Discovery found 1 tests in 101ms.
Running tests.
VERBOSE: Result is null: True
VERBOSE: Result is array: False
[-] Out-Something.Should not output anything 118ms (109ms|9ms)
Expected $null, but got [Object[]] '@()'.
at $result | Should-BeNull, /Users/johlju/source/Viscalyx.Common/tests/Unit/Public/Out-Something.tests.ps1:18
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.5.0
Possible Solution?
Hopefully I'm just doing something wrong. 🙂
Checklist
What is the issue?
I'm getting that the
$resultpassed toShould-BeNullis not$null, but the verbose output I added to debug this do say it is not an array and it is indeed$null. 🤔 Not sure if I'm doing something wrong. I have seen this in another place as well but ignored it there, when I got it here I thought this must be an error somewhere. 🙂The
Out-Diffcurrently only writesWrite-Informationmessages and returns no values.I output verbose message to determine that it is indeed $null and not an array, still
Should-BeNullthinks it is.Expected Behavior
Should pass test as the actual value is $null.
Steps To Reproduce
Running this reproduces the issue:
BeforeAll { function Out-Something { param ( ) } } Describe 'Out-Something' { It 'Should not output anything' { $result = $null $result = Out-Something Write-Verbose ("Result is null: {0}" -f ($null -eq $result)) -Verbose Write-Verbose ("Result is array: {0}" -f ($result -is [array])) -Verbose $result | Should-BeNull } }Returns:
Describe your environment
Possible Solution?
Hopefully I'm just doing something wrong. 🙂