MCPcopy Index your code
hub / github.com/nodejs/node / treeToXML

Function treeToXML

lib/internal/test_runner/reporter/junit.js:33–54  ·  view source on GitHub ↗
(tree)

Source from the content-addressed store, hash-verified

31}
32
33function treeToXML(tree) {
34 if (typeof tree === 'string') {
35 return `${escapeContent(tree)}\n`;
36 }
37 const {
38 tag, attrs, nesting, children, comment,
39 } = tree;
40 const indent = StringPrototypeRepeat('\t', nesting + 1);
41 if (comment) {
42 return `${indent}<!-- ${escapeComment(comment)} -->\n`;
43 }
44 const attrsString = ArrayPrototypeJoin(
45 ArrayPrototypeMap(
46 ObjectEntries(attrs),
47 ({ 0: key, 1: value }) => `${key}="${escapeAttribute(String(value))}"`),
48 ' ');
49 if (!children?.length) {
50 return `${indent}<${tag} ${attrsString}/>\n`;
51 }
52 const childrenString = ArrayPrototypeJoin(ArrayPrototypeMap(children ?? [], treeToXML), '');
53 return `${indent}<${tag} ${attrsString}>\n${childrenString}${indent}</${tag}>\n`;
54}
55
56function isFailure(node) {
57 return (node?.children && ArrayPrototypeSome(node.children, (c) => c.tag === 'failure')) || node?.attrs?.failures;

Callers 1

junit.jsFile · 0.85

Calls 4

escapeContentFunction · 0.85
escapeCommentFunction · 0.85
escapeAttributeFunction · 0.85
StringClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…