File tree Expand file tree Collapse file tree 1 file changed +19
-20
lines changed Expand file tree Collapse file tree 1 file changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -29,36 +29,35 @@ function merge(results) {
2929 return main_result ;
3030}
3131
32+ function getParser ( type ) {
33+ switch ( type ) {
34+ case 'testng' :
35+ return testng ;
36+ case 'junit' :
37+ return junit ;
38+ case 'xunit' :
39+ return xunit ;
40+ case 'mocha' :
41+ return mocha ;
42+ case 'cucumber' :
43+ return cucumber ;
44+ default :
45+ throw `UnSupported Result Type - ${ options . type } ` ;
46+ }
47+ }
48+
3249/**
3350 * @param {import('../index').ParseOptions } options
3451 */
3552function parse ( options ) {
53+ const parser = getParser ( options . type ) ;
3654 const results = [ ] ;
3755 for ( let i = 0 ; i < options . files . length ; i ++ ) {
3856 const matched_files = getMatchingFilePaths ( options . files [ i ] ) ;
3957 for ( let j = 0 ; j < matched_files . length ; j ++ ) {
4058 const file = matched_files [ j ] ;
41- switch ( options . type ) {
42- case 'testng' :
43- results . push ( testng . parse ( file ) ) ;
44- break ;
45- case 'junit' :
46- results . push ( junit . parse ( file ) ) ;
47- break ;
48- case 'xunit' :
49- results . push ( xunit . parse ( file ) ) ;
50- break ;
51- case 'mocha' :
52- results . push ( mocha . parse ( file ) ) ;
53- break ;
54- case 'cucumber' :
55- results . push ( cucumber . parse ( file ) ) ;
56- break ;
57- default :
58- throw `UnSupported Result Type - ${ options . type } ` ;
59- }
59+ results . push ( parser . parse ( file ) ) ;
6060 }
61-
6261 }
6362 return merge ( results ) ;
6463}
You can’t perform that action at this time.
0 commit comments