(
specName: Global.TestNameLike,
fn: Global.ConcurrentTestFn,
timeout?: number,
)
| 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 = () => { |
nothing calls this directly
no test coverage detected