MCPcopy
hub / github.com/jestjs/jest / restoreGlobalErrorHandlers

Function restoreGlobalErrorHandlers

packages/jest-circus/src/globalErrorHandlers.ts:46–66  ·  view source on GitHub ↗
(
  parentProcess: typeof Process,
  originalErrorHandlers: Circus.GlobalErrorHandlers,
)

Source from the content-addressed store, hash-verified

44};
45
46export const restoreGlobalErrorHandlers = (
47 parentProcess: typeof Process,
48 originalErrorHandlers: Circus.GlobalErrorHandlers,
49): void => {
50 parentProcess.removeListener('uncaughtException', uncaughtExceptionListener);
51 parentProcess.removeListener(
52 'unhandledRejection',
53 unhandledRejectionListener,
54 );
55 parentProcess.removeListener('rejectionHandled', rejectionHandledListener);
56
57 for (const listener of originalErrorHandlers.uncaughtException) {
58 parentProcess.on('uncaughtException', listener);
59 }
60 for (const listener of originalErrorHandlers.unhandledRejection) {
61 parentProcess.on('unhandledRejection', listener);
62 }
63 for (const listener of originalErrorHandlers.rejectionHandled) {
64 parentProcess.on('rejectionHandled', listener);
65 }
66};

Callers 1

eventHandlerFunction · 0.90

Calls 1

onMethod · 0.65

Tested by

no test coverage detected