Asserts that a function throws an error.
- If expected is a
string
orRegExp
, it will check themessage
property. - If expected is an
Error
object, it will check thename
andmessage
properties. - If expected is an
Error
constructor, it will check the class of theError
. - If expected is not provided, it will check if anything has thrown.