From c2b3ca2b112f7742da702a33e9b4710ff46d2e4d Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 4 Dec 2026 01:34:10 +0800 Subject: [PATCH] refactor(ci): simplify portable test failure details (#16415) --- scripts/ci/test-report.mjs | 40 +++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/scripts/ci/test-report.mjs b/scripts/ci/test-report.mjs index 4b9814e5fb5..4c7b3686afe 100644 --- a/scripts/ci/test-report.mjs +++ b/scripts/ci/test-report.mjs @@ -118,28 +118,24 @@ if (passed && verifyInventory) { const publishesHistory = passed && !selected; const skippedFiles = files.filter(({ state }) => state === "skipped"); const failureListLimit = 20; -const failureDetails = - !passed || failedFiles.length > 0 - ? [ - `Failed test modules reported: ${failedFiles.length}.`, - ...(incompleteFiles.length - ? [ - `Queued or pending test modules reported: ${incompleteFiles.length}.`, - ] - : []), - ...failedFiles - .slice(0, failureListLimit) - .map((name) => `- ${JSON.stringify(name)}`), - ...(failedFiles.length > failureListLimit - ? [ - `… ${failedFiles.length - failureListLimit} more in the test report.`, - ] - : []), - ...(report.unhandledErrors === undefined - ? [] - : [`Unhandled Vitest errors reported: ${report.unhandledErrors}.`]), - ] - : []; +const failureDetails = []; +if (!passed) { + failureDetails.push(`Failed test modules reported: ${failedFiles.length}.`); + if (incompleteFiles.length) + failureDetails.push( + `Queued or pending test modules reported: ${incompleteFiles.length}.`, + ); + for (const name of failedFiles.slice(0, failureListLimit)) + failureDetails.push(`- ${JSON.stringify(name)}`); + if (failedFiles.length > failureListLimit) + failureDetails.push( + `… ${failedFiles.length - failureListLimit} more in the test report.`, + ); + if (report.unhandledErrors !== undefined) + failureDetails.push( + `Unhandled Vitest errors reported: ${report.unhandledErrors}.`, + ); +} const shadowNotes = []; if ( process.env.CI_COMPARE_TEST_SHADOW === "true" &&