---
title: "Discussion on \"Using jest toThrow with async / await\" | Hashnode"
description: "Discussion on \"Using jest toThrow with async / await\". Instead of \nit(\"doesn't work\", async () => {\n  const fn = async () => {\n    throw new Error();\n  };\n\n  expect(await fn()).toThrow();\n});\n\nUse\nit(\"does work\", async () => {\n  const fn = async () => {\n    throw new Error();\n  };\n\n  await expect(fn()).r..."
url: "https://hashnode.com/posts/using-jest-tothrow-with-async-await/60bd38c0e36d51141c95d0a5"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Using jest toThrow with async / await](https://thmsobrmlr.hashnode.dev/using-jest-tothrow-with-async-await?utm_source=hashnode&utm_medium=feed)

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...

Jun 6, 2021 · 1 min read · thmsobrmlr.hashnode.dev  
Read the article

-   [#jest](https://hashnode.com/tag/jest)
-   [#async](https://hashnode.com/tag/async)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Thomas Obermüller](https://hashnode.com/@thmsobrmlr)

@thmsobrmlr

  
[View profile](https://hashnode.com/@thmsobrmlr)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
