MCPcopy
hub / github.com/vitest-dev/vitest / sendTasksUpdate

Function sendTasksUpdate

packages/runner/src/run.ts:477–495  ·  view source on GitHub ↗
(runner: VitestRunner)

Source from the content-addressed store, hash-verified

475const pendingTasksUpdates: Promise<void>[] = []
476
477function sendTasksUpdate(runner: VitestRunner): void {
478 if (packs.size) {
479 const taskPacks = Array.from(packs).map<TaskResultPack>(([id, task]) => {
480 return [id, task[0], task[1]]
481 })
482 const p = runner.onTaskUpdate?.(taskPacks, eventsPacks)
483 if (p) {
484 pendingTasksUpdates.push(p)
485 // remove successful promise to not grow array indefinitely,
486 // but keep rejections so finishSendTasksUpdate can handle them
487 p.then(
488 () => pendingTasksUpdates.splice(pendingTasksUpdates.indexOf(p), 1),
489 () => {},
490 )
491 }
492 eventsPacks.length = 0
493 packs.clear()
494 }
495}
496
497export async function finishSendTasksUpdate(runner: VitestRunner): Promise<void> {
498 sendTasksUpdate(runner)

Callers 1

finishSendTasksUpdateFunction · 0.85

Calls 3

clearMethod · 0.65
onTaskUpdateMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected