diff --git a/docs/api.assert.md b/docs/api.assert.md index c7c83ae..ec06d1f 100644 --- a/docs/api.assert.md +++ b/docs/api.assert.md @@ -131,6 +131,19 @@ assert.throws(() => OOPS(), /Cannot read property/); assert.throws(() => OOPS(), err => err instanceof TypeError); ``` +If you are trying to assert that an `async` function throws an Error, the following approach [is recommended](https://github.com/lukeed/uvu/issues/35#issuecomment-896270152): + +```js +try { + await asyncFnThatThrows(); + assert.unreachable('should have thrown'); +} catch (err) { + assert.instance(err, Error); + assert.match(err.message, 'something specific'); + assert.is(err.code, 'ERROR123'); +} +``` + ### unreachable(msg?: Message) Assert that a line should never be reached.