summaryrefslogtreecommitdiff
path: root/tests/unit_node/assert_test.ts
diff options
context:
space:
mode:
authorMarvin Hagemeister <marvin@deno.com>2024-07-08 21:28:39 +0200
committerGitHub <noreply@github.com>2024-07-08 21:28:39 +0200
commitb338b541ac828113667fdd24c18db97d3e47c282 (patch)
tree8906e1d917dc5cd5af331a3c9be651820743899c /tests/unit_node/assert_test.ts
parent86010bec092d074b161800da06149cfb79fb9f4b (diff)
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
Diffstat (limited to 'tests/unit_node/assert_test.ts')
-rw-r--r--tests/unit_node/assert_test.ts18
1 files changed, 18 insertions, 0 deletions
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,
+ );
+});