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

Function injectGlobalErrorHandlers

packages/jest-circus/src/globalErrorHandlers.ts:31–44  ·  view source on GitHub ↗
(
  parentProcess: typeof Process,
)

Source from the content-addressed store, hash-verified

29};
30
31export const injectGlobalErrorHandlers = (
32 parentProcess: typeof Process,
33): Circus.GlobalErrorHandlers => {
34 const uncaughtException = [...process.listeners('uncaughtException')];
35 const unhandledRejection = [...process.listeners('unhandledRejection')];
36 const rejectionHandled = [...process.listeners('rejectionHandled')];
37 parentProcess.removeAllListeners('uncaughtException');
38 parentProcess.removeAllListeners('unhandledRejection');
39 parentProcess.removeAllListeners('rejectionHandled');
40 parentProcess.on('uncaughtException', uncaughtExceptionListener);
41 parentProcess.on('unhandledRejection', unhandledRejectionListener);
42 parentProcess.on('rejectionHandled', rejectionHandledListener);
43 return {rejectionHandled, uncaughtException, unhandledRejection};
44};
45
46export const restoreGlobalErrorHandlers = (
47 parentProcess: typeof Process,

Callers 1

eventHandlerFunction · 0.90

Calls 1

onMethod · 0.65

Tested by

no test coverage detected