(test)
| 6 | const { Context } = mocha; |
| 7 | |
| 8 | function makeExecuteDeferred(test) { |
| 9 | return async function () { |
| 10 | /** @type {Array<() => Promise<void>>} */ |
| 11 | const deferredActions = test[kDeferred]; |
| 12 | |
| 13 | // process actions LIFO |
| 14 | const actions = Array.from(deferredActions).reverse(); |
| 15 | |
| 16 | try { |
| 17 | for (const fn of actions) { |
| 18 | await fn(); |
| 19 | } |
| 20 | } finally { |
| 21 | test[kDeferred].length = 0; |
| 22 | } |
| 23 | }; |
| 24 | } |
| 25 | |
| 26 | Context.prototype.defer = function defer(fn) { |
| 27 | const test = this.test; |