Pester
Pester copied to clipboard
Support mocking and execution in manifest modules
PR Summary
Adds support for manifest module to Mock, Should -Invoke and InModuleScope.
Fix #1456 Fix #933
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 Requestto mark it as a draft. PR can be markedReady for reviewwhen it's ready.
- If not, use the arrow next to
- [x] Tests are added/update (if required)
- [ ] Documentation is updated/added (if required)
Stumbled into an issue with force-importing manifest module with nested module, https://gist.github.com/fflaten/0df7afe3c2a781e2de29aeb55df0b8ff
This causes alias and mock to be placed in old import of a nested module while public function will execute in new and as a result not find the mock.
Workaround: Always remove manifest-module before re-importing. Ex.
BeforeAll {
Get-Module ManifestModule -ErrorAction SilentlyContinue | Remove-Module
Import-Module ManifestModule.psd1`
}
I believe this is intentional to avoid overwriting a module that was already imported in the session, while the manifest module will call the updated one (which we can see is updated in (Get-Module ManifestModule).NestedModules)