ParameterBindingValidationException: Cannot bind argument to parameter 'Frame' because it is null.
Checklist
- [X] Issue has a meaningful title
- [X] I have searched the existing issues. See all issues
- [X] I have tested using the latest version of Pester. See Installation and update guide.
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:

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
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.
Oh, I'm sorry. I just thought it was related because of the same error message
Don't be sorry, I was just trying to see if I am missing something 🙂