mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
b338b541ac
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
19 lines
363 B
TypeScript
19 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,
|
|
);
|
|
});
|