Open this example in the interactive library
Source code
import assert from "node:assert/strict";
await assert.rejects(async () => {
throw new TypeError("Invalid input");
}, TypeError);
console.log("Rejection matched");
Sample output
Rejection matched
