From 399dc2c708388af3024411658577625d0eab9379 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Mon, 27 Nov 2023 11:05:55 +0100 Subject: [PATCH] filter duplicated error messages in browser logs --- src/setup-page-script.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/setup-page-script.ts b/src/setup-page-script.ts index 3c8fbaa6..65c6b416 100644 --- a/src/setup-page-script.ts +++ b/src/setup-page-script.ts @@ -197,8 +197,10 @@ class StorybookTestRunnerError extends Error { const storyUrl = `${storybookUrl}?path=/story/${storyId}`; const finalStoryUrl = `${storyUrl}&addonPanel=storybook/interactions/panel`; const separator = '\n\n--------------------------------------------------'; + // The original error message will also be collected in the logs, so we filter it to avoid duplication + const finalLogs = logs.filter((err) => !err.includes(errorMessage)); const extraLogs = - logs.length > 0 ? separator + '\n\nBrowser logs:\n\n' + logs.join('\n\n') : ''; + finalLogs.length > 0 ? separator + '\n\nBrowser logs:\n\n' + finalLogs.join('\n\n') : ''; this.message = `\nAn error occurred in the following story. Access the link for full output:\n${finalStoryUrl}\n\nMessage:\n ${truncate( errorMessage,