How is it possible to unmock
a previously mocked function? Sometimes I find myself in a situation that I want to test a function that I previously mocked
.
A simplified example:
Describe 'Pester mocking' {
$testFile = Join-Path $env:TEMP 'test.txt'
It 'should be green' {
Mock Out-File
'Text' | Out-File -FilePath $testFile
Assert-MockCalled Out-File -Times 1 -Exactly
}
It 'should be green' {
# Unmock Out-File
'Text' | Out-File -FilePath $testFile
$testFile | Should -Exist
}
}