diff --git a/sandpack-react/src/components/Tests/FormattedError.tsx b/sandpack-react/src/components/Tests/FormattedError.tsx index 873f6443c..c4dff0e7b 100644 --- a/sandpack-react/src/components/Tests/FormattedError.tsx +++ b/sandpack-react/src/components/Tests/FormattedError.tsx @@ -44,7 +44,7 @@ const escapeHtml = (unsafe: string): string => { const formatDiffMessage = (error: TestError, path: string): string => { let finalMessage = ""; if (error.matcherResult) { - finalMessage = `${escapeHtml(error.message) + finalMessage = `${escapeHtml(error.message ?? "") .replace(/(expected)/m, `$1`) .replace(/(received)/m, `$1`) .replace(/(Difference:)/m, `$1`) @@ -62,7 +62,7 @@ const formatDiffMessage = (error: TestError, path: string): string => { `$1` )}`; } else { - finalMessage = escapeHtml(error.message); + finalMessage = escapeHtml(error.message ?? ""); } if (