In jest, If I run the following code:
await expect(async () => {
const asyncFunc = async () => {
return Promise.reject(new Error('Foo'))
};
await asyncFunc();
}).toThrow();
I would expect this pass as the promise rejects with an error, but this passes. Is there a way to assert the async function throws a the error?