Skip to content

Commit

Permalink
handle cross-realm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jan 15, 2025
1 parent 59cf055 commit 7877115
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/jest-core/src/lib/serializeToJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import {isNativeError} from 'node:util/types';

/**
* When we're asked to give a JSON output with the --json flag or otherwise,
* some data we need to return don't serialize well with a basic
Expand All @@ -21,7 +23,7 @@ export default function serializeToJSON(
(_, value) => {
// There might be more in Error, but pulling out just the message, name,
// and stack should be good enough
if (value instanceof Error) {
if (isNativeError(value)) {
return {
message: value.message,
name: value.name,
Expand Down

0 comments on commit 7877115

Please sign in to comment.