Suppose I have a function like this:
const f = async () => {
throw new Error('Huh???!');
};
And I want to test that it throws a RangeError
(not just an Error
) using Jest.
test('f throws a RangeError', () => {
expect(f()).rejects.toThrowError(RangeError);
});
However this test passes.
How can I check the type of the error thrown asyncronously in Jest?