Pester icon indicating copy to clipboard operation
Pester copied to clipboard

ParameterBindingValidationException: Cannot bind argument to parameter 'Frame' because it is null.

Open DarkLite1 opened this issue 3 years ago • 3 comments

Checklist

What is the issue?

Pester throws an internal exception when the wrong scope is used in combination with Should -Invoke

Expected Behavior

The test should simply fail with the normal error message from Should -Invoke

Steps To Reproduce

Run the following code:

Describe 'should be' {
    BeforeAll {
        Mock Get-Date
        Get-Date
    }
    It 'red with the standard text that the mock is not invoked' {
        Should -Invoke Get-Date -Times 1 -Exactly -Scope Context
    }
    It 'green' {
        Should -Invoke Get-Date -Times 1 -Exactly -Scope Describe
    }
}

Notice the thrown error: image

Describe your environment

Pester version     : 5.3.3 C:\Program Files\WindowsPowerShell\Modules\Pester\5.3.3\Pester.psm1
PowerShell version : 5.1.14393.5066
OS version         : Microsoft Windows NT 10.0.14393.0

Possible Solution?

Possibly related to #1784

DarkLite1 avatar Jun 02 '22 13:06 DarkLite1

What makes you think it is related? Same error message about parameter validation or something more?

The problem here is probably that it tries to find the block, but it finds none. And I did not handle that case at all.

nohwnd avatar Jun 02 '22 13:06 nohwnd

Oh, I'm sorry. I just thought it was related because of the same error message

DarkLite1 avatar Jun 02 '22 13:06 DarkLite1

Don't be sorry, I was just trying to see if I am missing something 🙂

nohwnd avatar Jun 02 '22 13:06 nohwnd