Skip to content

Commit 5796c95

Browse files
it-praktyknohwnd
authored andcommitted
The test for nonexisting module behavior check (pester#1040)
* The test for nonexising module behavior check * Fix mulitilined command
1 parent 27b4d09 commit 5796c95

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Functions/Mock.Tests.ps1

+13
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ Describe "When calling Mock on non-existing function" {
330330
}
331331
}
332332

333+
Describe "When calling Mock on non existent module" {
334+
335+
It "Should throw correct error" {
336+
$params = @{
337+
CommandName = 'Invoke-MyMethod'
338+
ModuleName = 'MyNonExistentModule'
339+
}
340+
341+
{ Mock @params -MockWith { write-host "my mock called!" } } | Should -Throw "No module named 'MyNonExistentModule' is currently loaded."
342+
}
343+
344+
}
345+
333346
Describe 'When calling Mock, StrictMode is enabled, and variables are used in the ParameterFilter' {
334347
Set-StrictMode -Version Latest
335348

0 commit comments

Comments
 (0)