Skip to content

assertThrowsErrorAsync

Assertion function that verifies an async function throws an error.

Returns the thrown error for further assertions.

import { assertThrowsErrorAsync } from "@kensio/smartass";
const error = await assertThrowsErrorAsync(async () => loadUser("missing"));
// error is returned as Error; this assertion does not narrow another value.

Source file: src/assert/throws-error-async/throws-error-async.assert.ts