Skip to content

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 setup!setup’s 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 'obsidian-dev-utils/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: