Skip to content

Commit 63f36b0

Browse files
committed
test_runner: fix potential TypeError in junit reporter
The junit reporter could crash with a TypeError if a test event was emitted without a `details` object. While `details` is common, its absence is a valid case that should not terminate the reporter.
1 parent 5816778 commit 63f36b0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • lib/internal/test_runner/reporter

lib/internal/test_runner/reporter/junit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ module.exports = async function* junitReporter(source) {
103103
if (currentSuite?.nesting === event.data.nesting) {
104104
currentSuite = currentSuite.parent;
105105
}
106-
currentTest.attrs.time = NumberPrototypeToFixed(event.data.details.duration_ms / 1000, 6);
106+
const duration = event.data.details?.duration_ms ?? 0;
107+
currentTest.attrs.time = NumberPrototypeToFixed(duration / 1000, 6);
107108
const nonCommentChildren = ArrayPrototypeFilter(currentTest.children, (c) => c.comment == null);
108109
if (nonCommentChildren.length > 0) {
109110
currentTest.tag = 'testsuite';

0 commit comments

Comments
 (0)