Skip to content

Commit 7877115

Browse files
committed
handle cross-realm errors
1 parent 59cf055 commit 7877115

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/jest-core/src/lib/serializeToJSON.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
import {isNativeError} from 'node:util/types';
9+
810
/**
911
* When we're asked to give a JSON output with the --json flag or otherwise,
1012
* some data we need to return don't serialize well with a basic
@@ -21,7 +23,7 @@ export default function serializeToJSON(
2123
(_, value) => {
2224
// There might be more in Error, but pulling out just the message, name,
2325
// and stack should be good enough
24-
if (value instanceof Error) {
26+
if (isNativeError(value)) {
2527
return {
2628
message: value.message,
2729
name: value.name,

0 commit comments

Comments
 (0)