diff --git a/lib/internal/test_runner/reporter/spec.js b/lib/internal/test_runner/reporter/spec.js index 2092d22e3fe77f..e3906a0392a32b 100644 --- a/lib/internal/test_runner/reporter/spec.js +++ b/lib/internal/test_runner/reporter/spec.js @@ -44,15 +44,27 @@ class SpecReporter extends Transform { assert(parent.type === 'test:start'); const msg = parent.data; ArrayPrototypeUnshift(this.#reported, msg); - prefix += `${indent(msg.nesting)}${reporterUnicodeSymbolMap['arrow:right']}${msg.name}\n`; + prefix += `${indent(msg.nesting)}${ + reporterUnicodeSymbolMap['arrow:right'] + }${msg.name}\n`; } let hasChildren = false; - if (this.#reported[0] && this.#reported[0].nesting === data.nesting && this.#reported[0].name === data.name) { + if ( + this.#reported[0] && + this.#reported[0].nesting === data.nesting && + this.#reported[0].name === data.name + ) { ArrayPrototypeShift(this.#reported); hasChildren = true; } const indentation = indent(data.nesting); - return `${formatTestReport(type, data, prefix, indentation, hasChildren)}\n`; + return `${formatTestReport( + type, + data, + prefix, + indentation, + hasChildren + )}\n`; } #handleEvent({ type, data }) { switch (type) { @@ -70,10 +82,19 @@ class SpecReporter extends Transform { case 'test:stdout': return data.message; case 'test:diagnostic': - return `${reporterColorMap[type]}${indent(data.nesting)}${reporterUnicodeSymbolMap[type]}${data.message}${colors.white}\n`; + const diagnosticColor = + reporterColorMap[data.level] || reporterColorMap['test:diagnostic']; + return `${diagnosticColor}${indent(data.nesting)}${ + reporterUnicodeSymbolMap[type] + }${data.message}${colors.white}\n`; case 'test:coverage': - return getCoverageReport(indent(data.nesting), data.summary, - reporterUnicodeSymbolMap['test:coverage'], colors.blue, true); + return getCoverageReport( + indent(data.nesting), + data.summary, + reporterUnicodeSymbolMap['test:coverage'], + colors.blue, + true + ); } } _transform({ type, data }, encoding, callback) { @@ -84,7 +105,9 @@ class SpecReporter extends Transform { callback(null, ''); return; } - const results = [`\n${reporterColorMap['test:fail']}${reporterUnicodeSymbolMap['test:fail']}failing tests:${colors.white}\n`]; + const results = [ + `\n${reporterColorMap['test:fail']}${reporterUnicodeSymbolMap['test:fail']}failing tests:${colors.white}\n`, + ]; for (let i = 0; i < this.#failedTests.length; i++) { const test = this.#failedTests[i]; const formattedErr = formatTestReport('test:fail', test);