From 30c0da3cd7d93647619c412e4a6d3555efe81ebd Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Tue, 28 Mar 2023 12:40:49 +0200 Subject: [PATCH] expand all parents of item that has an error --- src/logging/ConsoleReporter.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/logging/ConsoleReporter.ts b/src/logging/ConsoleReporter.ts index 328b4c23..9a43a123 100644 --- a/src/logging/ConsoleReporter.ts +++ b/src/logging/ConsoleReporter.ts @@ -49,12 +49,26 @@ function filterValues(values: LogItemValues): LogItemValues | null { }, null); } +function hasChildWithError(item: LogItem): boolean { + if (item.error) { + return true; + } + if (item.children) { + for(const c of item.children) { + if (hasChildWithError(c)) { + return true; + } + } + } + return false; +} + function printToConsole(item: LogItem): void { const label = `${itemCaption(item)} (@${item.start}ms, duration: ${item.duration}ms)`; const filteredValues = filterValues(item.values); const shouldGroup = item.children || filteredValues; if (shouldGroup) { - if (item.error) { + if (hasChildWithError(item)) { console.group(label); } else { console.groupCollapsed(label);