@@ -45,6 +45,8 @@ export interface LoadStaticHelpersOptions extends Partial<ModularEmitterOptions>
4545 sourcesDir ?: string ;
4646 rootDir ?: string ;
4747 program ?: Program ;
48+ /** When true, also load test helpers from static/test-helpers/ into test/generated/util/ */
49+ loadTestHelpers ?: boolean ;
4850}
4951
5052interface FileMetadata {
@@ -68,19 +70,24 @@ export async function loadStaticHelpers(
6870 options . program
6971 ) ;
7072 await loadFiles ( filesInSources , options . sourcesDir ?? "" ) ;
71- // Load static helpers used in testing code
72- const defaultTestingHelpersPath = path . join (
73- resolveProjectRoot ( ) ,
74- DEFAULT_SOURCES_TESTING_HELPERS_PATH
75- ) ;
76- const filesInTestings = await traverseDirectory (
77- defaultTestingHelpersPath ,
78- options . program ,
79- [ ] ,
80- "" ,
81- "test/generated/util"
82- ) ;
83- await loadFiles ( filesInTestings , options . rootDir ?? "" ) ;
73+ // Load static helpers used in testing code (only when loadTestHelpers is enabled)
74+ if (
75+ options . loadTestHelpers ??
76+ ( options . options ?. generateTest && isAzurePackage ( { options : options . options } ) )
77+ ) {
78+ const defaultTestingHelpersPath = path . join (
79+ resolveProjectRoot ( ) ,
80+ DEFAULT_SOURCES_TESTING_HELPERS_PATH
81+ ) ;
82+ const filesInTestings = await traverseDirectory (
83+ defaultTestingHelpersPath ,
84+ options . program ,
85+ [ ] ,
86+ "" ,
87+ "test/generated/util"
88+ ) ;
89+ await loadFiles ( filesInTestings , options . rootDir ?? "" ) ;
90+ }
8491 return assertAllHelpersLoadedPresent ( helpersMap ) ;
8592
8693 async function loadFiles ( files : FileMetadata [ ] , generateDir : string ) {
0 commit comments