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

Function concurrentFn

packages/jest-jasmine2/src/jasmineAsyncInstall.ts:202–233  ·  view source on GitHub ↗
(
    specName: Global.TestNameLike,
    fn: Global.ConcurrentTestFn,
    timeout?: number,
  )

Source from the content-addressed store, hash-verified

200 mutex: ReturnType<typeof pLimit>,
201): Global.ItConcurrentBase {
202 const concurrentFn = function (
203 specName: Global.TestNameLike,
204 fn: Global.ConcurrentTestFn,
205 timeout?: number,
206 ) {
207 let promise: Promise<unknown> = Promise.resolve();
208
209 const spec = originalFn.call(env, specName, () => promise, timeout);
210 if (env != null && !env.specFilter(spec)) {
211 return spec;
212 }
213
214 try {
215 promise = mutex(() => {
216 const promise = fn();
217 if (isPromise(promise)) {
218 return promise;
219 }
220 throw new Error(
221 `Jest: concurrent test "${spec.getFullName()}" must return a Promise.`,
222 );
223 });
224 } catch (error) {
225 promise = Promise.reject(error);
226 }
227 // Avoid triggering the uncaught promise rejection handler in case the test errors before
228 // being awaited on.
229 // eslint-disable-next-line @typescript-eslint/no-empty-function
230 promise.catch(() => {});
231
232 return spec;
233 };
234
235 // eslint-disable-next-line unicorn/consistent-function-scoping
236 const failing = () => {

Callers

nothing calls this directly

Calls 5

isPromiseFunction · 0.90
catchMethod · 0.80
fnFunction · 0.50
resolveMethod · 0.45
getFullNameMethod · 0.45

Tested by

no test coverage detected