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

Function formatTestReport

lib/internal/test_runner/reporter/utils.js:71–98  ·  view source on GitHub ↗
(type, data, showErrorDetails = true, prefix = '', indent = '')

Source from the content-addressed store, hash-verified

69}
70
71function formatTestReport(type, data, showErrorDetails = true, prefix = '', indent = '') {
72 let color = reporterColorMap[type] ?? colors.white;
73 let symbol = reporterUnicodeSymbolMap[type] ?? ' ';
74 const { skip, todo, expectFailure } = data;
75 const duration_ms = data.details?.duration_ms ? ` ${colors.gray}(${data.details.duration_ms}ms)${colors.white}` : '';
76 const replayed = data.details?.passed_on_attempt !== undefined ?
77 ` ${colors.gray}(passed on attempt ${data.details.passed_on_attempt})${colors.white}` :
78 '';
79 let title = `${data.name}${duration_ms}${replayed}`;
80
81 if (skip !== undefined) {
82 title += ` # ${typeof skip === 'string' && skip.length ? skip : 'SKIP'}`;
83 color = colors.gray;
84 symbol = reporterUnicodeSymbolMap['hyphen:minus'];
85 } else if (todo !== undefined) {
86 title += ` # ${typeof todo === 'string' && todo.length ? todo : 'TODO'}`;
87 if (type === 'test:fail') {
88 color = colors.yellow;
89 symbol = reporterUnicodeSymbolMap['warning:alert'];
90 }
91 } else if (expectFailure !== undefined) {
92 title += ` # EXPECTED FAILURE`;
93 }
94
95 const err = showErrorDetails && data.details?.error ? formatError(data.details.error, indent) : '';
96
97 return `${prefix}${indent}${color}${symbol}${title}${colors.white}${err}`;
98}
99
100module.exports = {
101 __proto__: null,

Callers 3

dot.jsFile · 0.85

Calls 1

formatErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…