Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/unitest/matcher/to_throw.ts>toThrow

🃏 Deno-first universal unit testing framework
Latest
function toThrow
import { toThrow } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/to_throw.ts";

Use .toThrow to test that a function throws when it is called

import { expect, test } from "https://deno.land/x/unitest@$VERSION/mod.ts";

test("passes when the function throw error", () => {
  expect(() => {
    throw Error("test");
  }).toThrow(/test/);
});

Parameters

actual: AnyFn
optional
expected: string | RegExp