Skip to content

Instantly share code, notes, and snippets.

@alx9r
Created April 6, 2018 20:50
Show Gist options
  • Save alx9r/824f89d0badc27cc9a3defc1d3293cda to your computer and use it in GitHub Desktop.
Save alx9r/824f89d0badc27cc9a3defc1d3293cda to your computer and use it in GitHub Desktop.
Example of mocking in nested modules for pester/Pester#1017
@{
RootModule = 'NestedMock.psm1'
ModuleVersion = '0.1.0'
}
Import-Module $PSScriptRoot\NestedMock1.psm1
Import-Module $PSScriptRoot\NestedMock2.psm1
Import-Module NestedMock -Force
Describe 'nested mock' {
InModuleScope NestedMock1 {
Mock f2 -Verifiable { Write-Host 'mock called' }
f1
It 'invoked mock' {
Assert-MockCalled f2
}
}
}
function f1 {
f2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment