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

Function asyncJestTest

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

Source from the content-addressed store, hash-verified

154 extraError.stack = originalExtraErrorStack;
155
156 const asyncJestTest = function (done: DoneFn) {
157 const wrappedFn = isGeneratorFn(fn) ? co.wrap(fn) : fn;
158 const returnValue = wrappedFn.call({}, doneFnNoop);
159
160 if (isPromise(returnValue)) {
161 returnValue.then(done.bind(null, null), (error: Error) => {
162 const {isError: checkIsError, message} = isError(error);
163
164 if (message) {
165 extraError.message = message;
166 extraError.stack =
167 originalExtraErrorStack &&
168 originalExtraErrorStack.replace('Error: ', `Error: ${message}`);
169 }
170
171 if (jasmine.Spec.isPendingSpecException(error)) {
172 env.pending(message!);
173 done();
174 } else {
175 done.fail(checkIsError ? error : extraError);
176 }
177 });
178 } else if (returnValue === undefined) {
179 done();
180 } else {
181 done.fail(
182 new Error(
183 'Jest: `it` and `test` must return either a Promise or undefined.',
184 ),
185 );
186 }
187 };
188
189 return originalFn.call(env, specName, asyncJestTest, timeout);
190 };

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected