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

Function withAwaitAsyncAssertions

packages/runner/src/suite.ts:567–582  ·  view source on GitHub ↗
(fn: T, task: TaskPopulated)

Source from the content-addressed store, hash-verified

565}
566
567function 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
584function createSuite() {
585 function suiteFn(

Callers 1

taskFunction · 0.85

Calls 2

filterMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected