Const
Calls the function and ensures it throws an error.
Optionally compares the error with expected. Allowed expected values:
expected
Usage
expect(() => { throw new Error('Something bad');}).toThrow();expect(() => { throw new Error('Something bad');}).toThrow(/something/);expect(() => { throw new Error('Something bad');}).toThrow(Error); Copy
expect(() => { throw new Error('Something bad');}).toThrow();expect(() => { throw new Error('Something bad');}).toThrow(/something/);expect(() => { throw new Error('Something bad');}).toThrow(Error);
Internal options that provide extra context for the matcher.
Received value.
Optional
Expected error message or error object.
Calls the function and ensures it throws an error.
Optionally compares the error with
expected. Allowed expected values:Usage