Skip to content

Commit

Permalink
fix: handle string errors in SandpackTests component (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangju2000 authored Sep 23, 2024
1 parent 8113f8a commit 23c1b8d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sandpack-react/src/components/Tests/FormattedError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const escapeHtml = (unsafe: string): string => {
const formatDiffMessage = (error: TestError, path: string): string => {
let finalMessage = "";
if (error.matcherResult) {
finalMessage = `<span>${escapeHtml(error.message)
finalMessage = `<span>${escapeHtml(error.message ?? "")
.replace(/(expected)/m, `<span class="${passTextClassName}">$1</span>`)
.replace(/(received)/m, `<span class="${failTextClassName}">$1</span>`)
.replace(/(Difference:)/m, `<span>$1</span>`)
Expand All @@ -62,7 +62,7 @@ const formatDiffMessage = (error: TestError, path: string): string => {
`<span class="${passTextClassName}">$1</span>`
)}</span>`;
} else {
finalMessage = escapeHtml(error.message);
finalMessage = escapeHtml(error.message ?? "");
}

if (
Expand Down

0 comments on commit 23c1b8d

Please sign in to comment.