import { expect } from "./expect.ts";import { AssertionError, assertThrows } from "../assert/mod.ts";
Deno.test("expect().toThrow()", () => { expect(() => { throw new Error("hello world"); }).toThrow();
expect(() => {}).not.toThrow();
assertThrows(() => { expect(() => {}).toThrow(); }, AssertionError);
assertThrows(() => { expect(() => { throw new Error("hello world"); }).not.toThrow(); }, AssertionError);
expect(() => { throw new AssertionError("hello world"); }).toThrow(AssertionError);
assertThrows( () => { expect(() => { throw new Error("hello world"); }).toThrow(AssertionError); }, AssertionError, 'Expected error to be instance of "AssertionError", but was "Error".', );
expect(() => { throw new AssertionError("hello world"); }).toThrow(new AssertionError("hello world"));
assertThrows( () => { expect(() => { throw new Error("hello world"); }).toThrow(new AssertionError("hello world")); }, AssertionError, 'Expected error to be instance of "AssertionError", but was "Error".', );
expect(() => { throw new AssertionError("hello world"); }).toThrow("hello");
assertThrows( () => { expect(() => { throw new AssertionError("hello world"); }).toThrow("goodbye"); }, AssertionError, 'Expected error message to include "goodbye", but got "hello world".', );
expect(() => { throw new AssertionError("hello world"); }).toThrow(new AssertionError("hello world"));
assertThrows( () => { expect(() => { throw new AssertionError("hello world"); }).toThrow(new AssertionError("goodbye")); }, AssertionError, 'Expected error message to include "goodbye", but got "hello world".', );
expect(() => { throw new AssertionError("hello world"); }).toThrow(/\w/);
assertThrows( () => { expect(() => { throw new Error("hello world"); }).toThrow(/\d/); }, AssertionError, 'Expected error message to include /\\d/, but got "hello world".', );});