@@ -142,14 +142,8 @@ Describe 'PathResolution extended scenarios' {
142142
143143 try {
144144 InModuleScope - ModuleName PathResolution {
145- Mock Get-Command {
146- param ($Name )
147- if ($Name -eq ' Exit-WithCode' ) {
148- return $null
149- }
150-
151- return Microsoft.PowerShell.Core\Get-Command @PSBoundParameters
152- }
145+ # ParameterFilter avoids Mock Get-Command recursion (stack overflow under coverage).
146+ Mock Get-Command - ParameterFilter { $Name -eq ' Exit-WithCode' } - MockWith { $null }
153147
154148 { Get-RepoRootSafe - ScriptPath $using :invalidPath - ExitOnError } | Should - Throw
155149 }
@@ -376,14 +370,8 @@ Describe 'PathResolution extended scenarios' {
376370
377371 try {
378372 InModuleScope - ModuleName PathResolution {
379- Mock Get-Command {
380- param ($Name )
381- if ($Name -eq ' Exit-WithCode' ) {
382- return $null
383- }
384-
385- return Microsoft.PowerShell.Core\Get-Command @PSBoundParameters
386- }
373+ # ParameterFilter avoids Mock Get-Command recursion (stack overflow under coverage).
374+ Mock Get-Command - ParameterFilter { $Name -eq ' Exit-WithCode' } - MockWith { $null }
387375
388376 { Get-RepoRootSafe - ScriptPath $using :invalidPath - ExitOnError } | Should - Throw
389377 }
@@ -472,14 +460,8 @@ Describe 'PathResolution extended scenarios' {
472460
473461 try {
474462 InModuleScope - ModuleName PathResolution {
475- Mock Get-Command {
476- param ($Name )
477- if ($Name -eq ' Exit-WithCode' ) {
478- return $null
479- }
480-
481- return Microsoft.PowerShell.Core\Get-Command @PSBoundParameters
482- }
463+ # ParameterFilter avoids Mock Get-Command recursion (stack overflow under coverage).
464+ Mock Get-Command - ParameterFilter { $Name -eq ' Exit-WithCode' } - MockWith { $null }
483465
484466 { Get-RepoRootSafe - ScriptPath $using :invalidPath - ExitOnError } | Should - Throw
485467 }
@@ -629,14 +611,8 @@ Describe 'PathResolution extended scenarios' {
629611 InModuleScope - ModuleName PathResolution - ArgumentList $invalidPath {
630612 param ([string ]$InvalidPath )
631613
632- Mock Get-Command {
633- param ($Name )
634- if ($Name -eq ' Exit-WithCode' ) {
635- return $null
636- }
637-
638- return Microsoft.PowerShell.Core\Get-Command @PSBoundParameters
639- }
614+ # ParameterFilter avoids Mock Get-Command recursion (stack overflow under coverage).
615+ Mock Get-Command - ParameterFilter { $Name -eq ' Exit-WithCode' } - MockWith { $null }
640616
641617 { Get-RepoRootSafe - ScriptPath $InvalidPath - ExitOnError } | Should - Throw
642618 }
0 commit comments