Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle string errors in SandpackTests component #1208

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading