I have seen this question which expects a Promise
to work. In my case the Error
is thrown before and outside a Promise
.
How can I assert the error in this case? I have tried the options below.
test('Method should throw Error', async () => {
let throwThis = async () => {
throw new Error();
};
await expect(throwThis).toThrow(Error);
await expect(throwThis).rejects.toThrow(Error);
});