Skip to content

Commit 5d04c1f

Browse files
committed
Extract line and filePath if available
1 parent 6e68fa7 commit 5d04c1f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/convert.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface JUnitTestCase {
1616
errorTrace: string | undefined,
1717
errorMessage: string | undefined,
1818
errorType: string | undefined,
19+
file?: string,
20+
lineno?: string,
1921
skipped?: boolean;
2022
}
2123

@@ -28,7 +30,7 @@ async function parseJUnitReport(filePath: string): Promise<JUnitTestCase[]> {
2830
const parseTestSuite = (suite: any, suiteName: string) => {
2931
if (suite.testcase) {
3032
suite.testcase.forEach((testCase: any) => {
31-
const { classname, name, time } = testCase.$;
33+
const { classname, file, lineno, name, time } = testCase.$;
3234

3335
const hasFailure = testCase.failure !== undefined;
3436
const failureTrace = hasFailure ? (testCase.failure[0]?._ || '') : undefined;
@@ -46,6 +48,8 @@ async function parseJUnitReport(filePath: string): Promise<JUnitTestCase[]> {
4648
classname,
4749
name,
4850
time,
51+
file,
52+
lineno,
4953
hasFailure,
5054
failureTrace,
5155
failureMessage,
@@ -101,10 +105,14 @@ function convertToCTRFTest(testCase: JUnitTestCase, useSuiteName: boolean): Ctrf
101105
? `${testCase.suite}: ${testCase.name}`
102106
: testCase.name;
103107

108+
const line = testCase.lineno ? parseInt(testCase.lineno) : undefined;
109+
104110
return {
105111
name: testName,
106112
status,
107113
duration: durationMs,
114+
filePath: testCase.file,
115+
line: line,
108116
message: testCase.failureMessage || testCase.errorMessage || undefined,
109117
trace: testCase.failureTrace || testCase.errorTrace || undefined,
110118
suite: testCase.suite || '',

0 commit comments

Comments
 (0)