Asserts that a function throws an error.
- If expected is a
stringorRegExp, it will check themessageproperty. - If expected is an
Errorobject, it will check thenameandmessageproperties. - If expected is an
Errorconstructor, it will check the class of theError. - If expected is not provided, it will check if anything has thrown.