@@ -2966,4 +2966,43 @@ i -PassThru:$PassThru {
29662966 $ex.Exception.Message | Verify- Like ' *Unbound scriptblock*'
29672967 }
29682968 }
2969+
2970+ # Regression test for https://github.com/pester/Pester/issues/2515
2971+ # Find-File should discover test files inside hidden (dot-prefixed) directories.
2972+ # Without -Force on Get-ChildItem, hidden folders are silently skipped.
2973+ b " Find-File discovers hidden folders" {
2974+ t " discovers test files in dot-prefixed (hidden) subdirectories" {
2975+ $tempDir = Join-Path ([IO.Path ]::GetTempPath()) " PesterHidden_$ ( [IO.Path ]::GetRandomFileName().Substring(0 , 4 )) "
2976+ $hiddenDir = Join-Path $tempDir ' .hidden'
2977+ $null = New-Item - ItemType Directory - Path $hiddenDir - Force
2978+ $testFile = Join-Path $hiddenDir ' MyHidden.Tests.ps1'
2979+ Set-Content - Path $testFile - Value " Describe 'Hidden' { It 'works' { `$ true | Should -Be `$ true } }"
2980+
2981+ try {
2982+ $found = & (Get-Module Pester) { Find-File - Path $args [0 ] - Extension ' .Tests.ps1' } $tempDir
2983+ $found | Should -Not - BeNullOrEmpty
2984+ ($found | ForEach-Object { $_.FullName }) | Should - Contain $testFile
2985+ }
2986+ finally {
2987+ Remove-Item - Path $tempDir - Recurse - Force
2988+ }
2989+ }
2990+
2991+ t " discovers test files in nested hidden directories" {
2992+ $tempDir = Join-Path ([IO.Path ]::GetTempPath()) " PesterHidden2_$ ( [IO.Path ]::GetRandomFileName().Substring(0 , 4 )) "
2993+ $nestedHidden = Join-Path $tempDir ' .config/tests'
2994+ $null = New-Item - ItemType Directory - Path $nestedHidden - Force
2995+ $testFile = Join-Path $nestedHidden ' Deep.Tests.ps1'
2996+ Set-Content - Path $testFile - Value " Describe 'Deep' { It 'works' { `$ true | Should -Be `$ true } }"
2997+
2998+ try {
2999+ $found = & (Get-Module Pester) { Find-File - Path $args [0 ] - Extension ' .Tests.ps1' } $tempDir
3000+ $found | Should -Not - BeNullOrEmpty
3001+ ($found | ForEach-Object { $_.FullName }) | Should - Contain $testFile
3002+ }
3003+ finally {
3004+ Remove-Item - Path $tempDir - Recurse - Force
3005+ }
3006+ }
3007+ }
29693008}
0 commit comments