(predicate: () => boolean)
| 690 | } |
| 691 | |
| 692 | async function waitFor(predicate: () => boolean): Promise<void> { |
| 693 | for (let attempt = 0; attempt < 50; attempt += 1) { |
| 694 | if (predicate()) return; |
| 695 | await new Promise<void>((resolve) => setImmediate(resolve)); |
| 696 | } |
| 697 | assert.fail('condition was not met'); |
| 698 | } |
| 699 | |
| 700 | async function within<T>(promise: Promise<T>, operation: string): Promise<T> { |
| 701 | let timeout: NodeJS.Timeout | undefined; |
no test coverage detected