@@ -16,8 +16,13 @@ import {
1616
1717import { DetectionConfig } from "../percy-snapshot-utils/types.js" ;
1818
19- async function walkDir ( dir : string , extensions : string [ ] ) : Promise < string [ ] > {
19+ async function walkDir (
20+ dir : string ,
21+ extensions : string [ ] ,
22+ depth : number = 6 ,
23+ ) : Promise < string [ ] > {
2024 const result : string [ ] = [ ] ;
25+ if ( depth < 0 ) return result ;
2126 try {
2227 const entries = await fs . promises . readdir ( dir , { withFileTypes : true } ) ;
2328
@@ -26,7 +31,7 @@ async function walkDir(dir: string, extensions: string[]): Promise<string[]> {
2631
2732 if ( entry . isDirectory ( ) ) {
2833 if ( ! EXCLUDED_DIRS . has ( entry . name ) && ! entry . name . startsWith ( "." ) ) {
29- result . push ( ...( await walkDir ( fullPath , extensions ) ) ) ;
34+ result . push ( ...( await walkDir ( fullPath , extensions , depth - 1 ) ) ) ;
3035 }
3136 } else if ( extensions . some ( ( ext ) => entry . name . endsWith ( ext ) ) ) {
3237 result . push ( fullPath ) ;
@@ -112,7 +117,7 @@ export async function listTestFiles(
112117 // Step 1: Collect all files with matching extensions
113118 let files : string [ ] = [ ] ;
114119 try {
115- files = await walkDir ( baseDir , config . extensions ) ;
120+ files = await walkDir ( baseDir , config . extensions , 6 ) ;
116121 } catch {
117122 return [ ] ;
118123 }
@@ -151,7 +156,7 @@ export async function listTestFiles(
151156 // Step 4: Handle SpecFlow .feature files for C# + SpecFlow
152157 if ( language === "csharp" && framework === "specflow" ) {
153158 try {
154- const featureFiles = await walkDir ( baseDir , [ ".feature" ] ) ;
159+ const featureFiles = await walkDir ( baseDir , [ ".feature" ] , 6 ) ;
155160 featureFiles . forEach ( ( file ) => candidateFiles . set ( file , 2 ) ) ;
156161 logger . info ( `Added ${ featureFiles . length } SpecFlow .feature files` ) ;
157162 } catch {
0 commit comments