@@ -61,7 +61,7 @@ async function parseJUnitReport(filePath: string): Promise<JUnitTestCase[]> {
61
61
return testCases ;
62
62
}
63
63
64
- function convertToCTRFTest ( testCase : JUnitTestCase ) : CtrfTest {
64
+ function convertToCTRFTest ( testCase : JUnitTestCase , useSuiteName : boolean ) : CtrfTest {
65
65
let status : CtrfTest [ 'status' ] = 'other' ;
66
66
67
67
if ( testCase . failure ) {
@@ -76,21 +76,27 @@ function convertToCTRFTest(testCase: JUnitTestCase): CtrfTest {
76
76
77
77
const durationMs = Math . round ( parseFloat ( testCase . time ) * 1000 ) ;
78
78
79
+ const testName = useSuiteName
80
+ ? `${ testCase . suite } : ${ testCase . name } `
81
+ : testCase . name ;
82
+
79
83
return {
80
- name : ` ${ testCase . suite } : ${ testCase . name } ` ,
84
+ name : testName ,
81
85
status,
82
86
duration : durationMs ,
83
87
message : testCase . failure || testCase . error ? ( testCase . failure || testCase . error ) : undefined ,
84
88
trace : testCase . failure || testCase . error ? ( testCase . failure || testCase . error ) : undefined ,
89
+ suite : testCase . suite || ''
85
90
} ;
86
91
}
87
92
88
93
function createCTRFReport (
89
94
testCases : JUnitTestCase [ ] ,
90
95
toolName ?: string ,
91
- envProps ?: Record < string , any >
96
+ envProps ?: Record < string , any > ,
97
+ useSuiteName ?: boolean
92
98
) : CtrfReport {
93
- const ctrfTests = testCases . map ( convertToCTRFTest ) ;
99
+ const ctrfTests = testCases . map ( testCase => convertToCTRFTest ( testCase , ! ! useSuiteName ) ) ;
94
100
const passed = ctrfTests . filter ( test => test . status === 'passed' ) . length ;
95
101
const failed = ctrfTests . filter ( test => test . status === 'failed' ) . length ;
96
102
const skipped = ctrfTests . filter ( test => test . status === 'skipped' ) . length ;
@@ -131,11 +137,12 @@ export async function convertJUnitToCTRF(
131
137
junitPath : string ,
132
138
outputPath ?: string ,
133
139
toolName ?: string ,
134
- envProps ?: string [ ]
140
+ envProps ?: string [ ] ,
141
+ useSuiteName ?: boolean
135
142
) : Promise < void > {
136
143
const testCases = await parseJUnitReport ( junitPath ) ;
137
144
const envPropsObj = envProps ? Object . fromEntries ( envProps . map ( prop => prop . split ( '=' ) ) ) : { } ;
138
- const ctrfReport = createCTRFReport ( testCases , toolName , envPropsObj ) ;
145
+ const ctrfReport = createCTRFReport ( testCases , toolName , envPropsObj , useSuiteName ) ;
139
146
140
147
const defaultOutputPath = path . join ( 'ctrf' , 'ctrf-report.json' ) ;
141
148
const finalOutputPath = path . resolve ( outputPath || defaultOutputPath ) ;
0 commit comments