drainCollectedUnhandledAsyncErrors
Empties the collection window opened by startCollectingUnhandledAsyncErrors and returns what it held, leaving the window open so errors emitted afterwards keep being collected.
This is what the test setup’s (@mnaoumov/typescript-test-toolkit/setup) beforeEach / afterEach use, rather than stopCollectingUnhandledAsyncErrors: an async error emitted in the gap between two tests (e.g. by a setTimeout the test left pending) would otherwise land on a closed window and vanish unreported.
Import:
import { drainCollectedUnhandledAsyncErrors } from '@mnaoumov/typescript-lib/error';Signature:
function drainCollectedUnhandledAsyncErrors(): unknown[]Returns: unknown[] — The unhandled async errors collected so far, or an empty array if no window is open.
Links to this page: