I\'m working with some code where I need to test the type of an exception thrown by a function (is it TypeError, ReferenceError, etc.?).
My current testing framework
Jest has a method, toThrow(error), to test that a function throws when it is called.
toThrow(error)
So, in your case you should call it so:
expect(t).toThrowError(TypeError);
The documentation.