* A `setImmediate` callback runs in the check phase — AFTER the microtask queue * drains. So if `await maybeYield()` did NOT cross a macrotask boundary (it was * under budget and returned a synchronously-resolved promise), a `setImmediate` * scheduled just before it has NOT fired yet. If it DID y
(maybeYield: () => Promise<void>)
| 25 | * This makes "did it yield?" a deterministic, non-timing assertion. |
| 26 | */ |
| 27 | async function yieldedDuring(maybeYield: () => Promise<void>): Promise<boolean> { |
| 28 | let macrotaskRan = false; |
| 29 | setImmediate(() => { macrotaskRan = true; }); |
| 30 | await maybeYield(); |
| 31 | return macrotaskRan; |
| 32 | } |
| 33 | |
| 34 | describe('createYielder', () => { |
| 35 | it('does not yield while under the time budget', async () => { |
no outgoing calls
no test coverage detected