1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00
denoland-deno/tests/unit_node/assert_test.ts
Marvin Hagemeister b338b541ac
fix(node/assert): throws not checking error instance (#24466)
The implementation for `assert.throws()` from `node:assert` didn't work
when the expected value was an `Error` constructor. In this case the
thrown error should checked if it's an instance of said constructor.

Fixes https://github.com/denoland/deno/issues/24464
2024-07-08 21:28:39 +02:00

18 lines
363 B
TypeScript

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import * as assert from "node:assert";
Deno.test("[node/assert] .throws() compares Error instance", () => {
assert.throws(
() => {
throw new Error("FAIL");
},
Error,
);
assert.throws(
() => {
throw new TypeError("FAIL");
},
TypeError,
);
});