From b338b541ac828113667fdd24c18db97d3e47c282 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Mon, 8 Jul 2024 21:28:39 +0200 Subject: 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 --- tests/unit_node/assert_test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/unit_node/assert_test.ts (limited to 'tests/unit_node') diff --git a/tests/unit_node/assert_test.ts b/tests/unit_node/assert_test.ts new file mode 100644 index 000000000..dc565458f --- /dev/null +++ b/tests/unit_node/assert_test.ts @@ -0,0 +1,18 @@ +// 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, + ); +}); -- cgit v1.2.3