Skip to content

Commit bd2633a

Browse files
committed
implement the rest of failure element
1 parent 5eb8930 commit bd2633a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

javascript/src/index.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,18 @@ export default {
5353
time: testCase.time,
5454
})
5555
if (testCase.failure) {
56-
testcaseElement.ele(testCase.failure.type)
56+
const failureElement = testcaseElement.ele(testCase.failure.kind)
57+
if (testCase.failure.kind === 'failure' && testCase.failure.type) {
58+
failureElement.att('type', testCase.failure.type)
59+
}
60+
if (testCase.failure.message) {
61+
failureElement.att('message', testCase.failure.message)
62+
}
63+
if (testCase.failure.stack) {
64+
failureElement.cdata(testCase.failure.stack)
65+
}
5766
}
58-
testcaseElement.ele('system-out', {}).cdata(testCase.output)
67+
testcaseElement.ele('system-out').cdata(testCase.output)
5968
}
6069

6170
write(builder.end({ pretty: true }))
@@ -82,7 +91,10 @@ interface ReportTestCase {
8291
}
8392

8493
interface ReportFailure {
85-
type: 'failure' | 'skipped'
94+
kind: 'failure' | 'skipped'
95+
type?: string
96+
message?: string
97+
stack?: string
8698
}
8799

88100
function makeReport(query: ExtendedQuery): ReportSuite {
@@ -136,6 +148,9 @@ function makeFailure(
136148
return undefined
137149
}
138150
return {
139-
type: result.status === TestStepResultStatus.SKIPPED ? 'skipped' : 'failure',
151+
kind: result.status === TestStepResultStatus.SKIPPED ? 'skipped' : 'failure',
152+
type: result.exception?.type,
153+
message: result.exception?.message,
154+
stack: result.exception?.stackTrace ?? result.message,
140155
}
141156
}

0 commit comments

Comments
 (0)