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

Function asyncJestLifecycle

packages/jest-jasmine2/src/jasmineAsyncInstall.ts:78–97  ·  view source on GitHub ↗
(done: DoneFn)

Source from the content-addressed store, hash-verified

76 // We make *all* functions async and run `done` right away if they
77 // didn't return a promise.
78 const asyncJestLifecycle = function (done: DoneFn) {
79 const wrappedFn = isGeneratorFn(fn) ? co.wrap(fn) : fn;
80 const returnValue = wrappedFn.call({}, doneFnNoop);
81
82 if (isPromise(returnValue)) {
83 returnValue.then(done.bind(null, null), (error: Error) => {
84 const {isError: checkIsError, message} = isError(error);
85
86 if (message) {
87 extraError.message = message;
88 extraError.stack =
89 originalExtraErrorStack &&
90 originalExtraErrorStack.replace('Error: ', `Error: ${message}`);
91 }
92 done.fail(checkIsError ? error : extraError);
93 });
94 } else {
95 done();
96 }
97 };
98
99 return originalFn.call(env, asyncJestLifecycle, timeout);
100 };

Callers

nothing calls this directly

Calls 5

isPromiseFunction · 0.90
doneFunction · 0.85
thenMethod · 0.80
failMethod · 0.80
isErrorFunction · 0.70

Tested by

no test coverage detected