MCPcopy Index your code
hub / github.com/nodejs/node / waitForActual

Function waitForActual

lib/assert.js:597–620  ·  view source on GitHub ↗
(promiseFn)

Source from the content-addressed store, hash-verified

595}
596
597async function waitForActual(promiseFn) {
598 let resultPromise;
599 if (typeof promiseFn === 'function') {
600 // Return a rejected promise if `promiseFn` throws synchronously.
601 resultPromise = promiseFn();
602 // Fail in case no promise is returned.
603 if (!checkIsPromise(resultPromise)) {
604 throw new ERR_INVALID_RETURN_VALUE('instance of Promise',
605 'promiseFn', resultPromise);
606 }
607 } else if (checkIsPromise(promiseFn)) {
608 resultPromise = promiseFn;
609 } else {
610 throw new ERR_INVALID_ARG_TYPE(
611 'promiseFn', ['Function', 'Promise'], promiseFn);
612 }
613
614 try {
615 await resultPromise;
616 } catch (e) {
617 return e;
618 }
619 return NO_EXCEPTION_SENTINEL;
620}
621
622function expectsError(stackStartFn, actual, error, message) {
623 if (typeof error === 'string') {

Callers 1

assert.jsFile · 0.85

Calls 2

promiseFnFunction · 0.85
checkIsPromiseFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…