Skip to main content
Module

x/unitest/mod.ts>toThrow

🃏 Deno-first universal unit testing framework
Latest
function toThrow
Re-export
import { toThrow } from "https://deno.land/x/unitest@v1.0.0-beta.82/mod.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