Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion packages/jest-circus/src/formatNodeAssertErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ const formatNodeAssertErrors = (
error = asyncError;
} else if (originalError.stack) {
error = originalError;
} else {
} else if (asyncError) {
error = asyncError;

error.message =
originalError.message ||
`thrown: ${prettyFormat(originalError, {maxDepth: 3})}`;
} else {
error = new Error(
originalError.message ||
`thrown: ${prettyFormat(originalError, {maxDepth: 3})}`,
);
}
} else {
error = errors;
Expand Down
7 changes: 5 additions & 2 deletions packages/jest-circus/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,12 @@ const _getError = (
return error;
}

asyncError.message = `thrown: ${prettyFormat(error, {maxDepth: 3})}`;
if (asyncError) {
asyncError.message = `thrown: ${prettyFormat(error, {maxDepth: 3})}`;
return asyncError;
}

return asyncError;
return new Error(`thrown: ${prettyFormat(error, {maxDepth: 3})}`);
};

const getErrorStack = (error: Error): string =>
Expand Down
Loading