Function
withAwaitAsyncAssertions
(fn: T, task: TaskPopulated)
Source from the content-addressed store, hash-verified
| 565 | } |
| 566 | |
| 567 | function withAwaitAsyncAssertions<T extends (...args: any[]) => any>(fn: T, task: TaskPopulated): T { |
| 568 | return (async (...args: any[]) => { |
| 569 | const fnResult = await fn(...args) |
| 570 | // some async expect will be added to this array, in case user forget to await them |
| 571 | if (task.promises) { |
| 572 | const result = await Promise.allSettled(task.promises) |
| 573 | const errors = result |
| 574 | .map(r => (r.status === 'rejected' ? r.reason : undefined)) |
| 575 | .filter(Boolean) |
| 576 | if (errors.length) { |
| 577 | throw errors |
| 578 | } |
| 579 | } |
| 580 | return fnResult |
| 581 | }) as T |
| 582 | } |
| 583 | |
| 584 | function createSuite() { |
| 585 | function suiteFn( |
Tested by
no test coverage detected