Using jest toThrow with async / await
Instead of
it("doesn't work", async () => {
const fn = async () => {
throw new Error();
};
expect(await fn()).toThrow();
});
Use
it("does work", async () => {
const fn = async () => {
throw new Error();
};
await expect(fn()).r...
thmsobrmlr.hashnode.dev1 min read