Pester
Pester copied to clipboard
Improve error when -HaveParameter is used with mock or alias for local function
PR Summary
PowerShell doesn't resolve local functions properly for AliasInfo
when function is defined in local scope in different session state. This affects use of -HaveParameter
on a mocked command, ex. Get-Command Should -HaveParameter mockedCommand
Replace generic NRE with exception that suggests a workaround as this problem is unlikely to be fixed soon in PowerShell and probably not at all in Windows PowerShell.
Fix #1431
PR Checklist
- [x] PR has meaningful title
- [x] Summary describes changes
- [x] PR is ready to be merged
- If not, use the arrow next to
Create Pull Request
to mark it as a draft. PR can be markedReady for review
when it's ready.
- If not, use the arrow next to
- [x] Tests are added/update (if required)
- [ ] Documentation is updated/added (if required)
Looking for feedback:
- Throw vs failure message?
- Should we stick with
Where-Object Parameters
workaround for both scenarios to keep it simple?
Looks good, I would start from throwing, it is better to make the user correct their test, than us having to support yet another scenario where we "guess" for the user.
Again pending comments. :/
Pending #2267 to fix CI
/azp run
Azure Pipelines successfully started running 1 pipeline(s).