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

Function _addHook

packages/jest-circus/src/index.ts:93–109  ·  view source on GitHub ↗
(
  fn: Circus.HookFn,
  hookType: Circus.HookType,
  hookFn: THook,
  timeout?: number,
)

Source from the content-addressed store, hash-verified

91};
92
93const _addHook = (
94 fn: Circus.HookFn,
95 hookType: Circus.HookType,
96 hookFn: THook,
97 timeout?: number,
98) => {
99 const asyncError = new ErrorWithStack(undefined, hookFn);
100
101 if (typeof fn !== 'function') {
102 asyncError.message =
103 'Invalid first argument. It must be a callback function.';
104
105 throw asyncError;
106 }
107
108 dispatchSync({asyncError, fn, hookType, name: 'add_hook', timeout});
109};
110
111// Hooks have to pass themselves to the HOF in order for us to trim stack traces.
112const beforeEach: THook = (fn, timeout) =>

Callers 4

beforeEachFunction · 0.85
beforeAllFunction · 0.85
afterEachFunction · 0.85
afterAllFunction · 0.85

Calls 1

dispatchSyncFunction · 0.90

Tested by

no test coverage detected