I have the following simple test in Pester:
# Name.Tests.ps1
$name = "foo"
Describe "Check name" {
It "should have the correct value" {
$name | Should -Be "foo"
}
}
So when I navigate to the folder containing the test script and run Invoke-Pester
, I was expecting the test to pass. Instead, I get the following error:
[-]Check name.should have the correct value. Expected 'foo', but got $null...
Any idea why this fails and why $name
is set to null in the It
block - shouldn't $name
still be set to foo
as it's from the parent scope?