Skip to content

Commit fe4ac69

Browse files
committed
Fix runGlobalHook error when message is unwritable
1 parent 57e9872 commit fe4ac69

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/jest-core/src/runGlobalHook.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ export default async function runGlobalHook({
5959
},
6060
);
6161
} catch (error) {
62-
if (util.types.isNativeError(error)) {
62+
if (
63+
util.types.isNativeError(error) &&
64+
(Object.getOwnPropertyDescriptor(error, 'message')?.writable ||
65+
Object.getOwnPropertyDescriptor(
66+
Object.getPrototypeOf(error),
67+
'message',
68+
)?.writable)
69+
) {
6370
error.message = `Jest: Got error running ${moduleName} - ${modulePath}, reason: ${error.message}`;
6471

6572
throw error;

0 commit comments

Comments
 (0)