Skip to content

Commit

Permalink
Merge pull request #405 from storybookjs/fix/filter-duplicated-error-…
Browse files Browse the repository at this point in the history
…messages

Filter duplicated error messages in browser logs
  • Loading branch information
yannbf authored Nov 27, 2023
2 parents 5db9536 + 399dc2c commit ad3d401
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/setup-page-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ad3d401

Please sign in to comment.