@@ -7,19 +7,19 @@ import { glob } from 'glob';
77 * @param globPattern - The glob pattern to match JUnit XML files
88 * @returns Promise resolving to an array of all test cases from all matching files
99 */
10- export async function readJUnitReportsFromGlob ( globPattern : string ) : Promise < JUnitTestCase [ ] > {
11- console . log ( 'Searching for JUnit reports matching pattern:' , globPattern ) ;
10+ export async function readJUnitReportsFromGlob ( globPattern : string , options : { log ?: boolean } = { } ) : Promise < JUnitTestCase [ ] > {
11+ if ( options . log ) console . log ( 'Searching for JUnit reports matching pattern:' , globPattern ) ;
1212
1313 const files = await glob ( globPattern ) ;
1414
1515 if ( files . length === 0 ) {
16- console . warn ( 'No files found matching the pattern:' , globPattern ) ;
16+ if ( options . log ) console . warn ( 'No files found matching the pattern:' , globPattern ) ;
1717 return [ ] ;
1818 }
1919
20- console . log ( `Found ${ files . length } JUnit report files` ) ;
20+ if ( options . log ) console . log ( `Found ${ files . length } JUnit report files` ) ;
2121
22- const allTestCasesPromises = files . map ( file => parseJUnitReport ( file ) ) ;
22+ const allTestCasesPromises = files . map ( file => parseJUnitReport ( file , options ) ) ;
2323 const testCasesArrays = await Promise . all ( allTestCasesPromises ) ;
2424
2525 return testCasesArrays . flat ( ) ;
@@ -30,8 +30,8 @@ export async function readJUnitReportsFromGlob(globPattern: string): Promise<JUn
3030 * @param filePath - Path to the JUnit XML file
3131 * @returns Promise resolving to an array of test cases
3232 */
33- export async function parseJUnitReport ( filePath : string ) : Promise < JUnitTestCase [ ] > {
34- console . log ( 'Reading JUnit report file:' , filePath ) ;
33+ export async function parseJUnitReport ( filePath : string , options : { log ?: boolean } = { } ) : Promise < JUnitTestCase [ ] > {
34+ if ( options . log ) console . log ( 'Reading JUnit report file:' , filePath ) ;
3535 const xml = await fs . readFile ( filePath , 'utf-8' ) ;
3636 const result = await xml2js . parseStringPromise ( xml ) ;
3737 const testCases : JUnitTestCase [ ] = [ ] ;
@@ -89,7 +89,7 @@ export async function parseJUnitReport(filePath: string): Promise<JUnitTestCase[
8989 const suiteName = suite . $ . name ;
9090 parseTestSuite ( suite , suiteName ) ;
9191 } else {
92- console . warn ( 'No test suites found in the provided file.' ) ;
92+ if ( options . log ) console . warn ( 'No test suites found in the provided file.' ) ;
9393 }
9494
9595 return testCases ;
0 commit comments