-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async / Await expect().toThrow() does not work as expected #5538
Comments
However this passes: async function throws () {
throw new Error('hello world')
}
test('promise throws', async () => {
let message = false
try {
await throws()
} catch (e) {
message = e.message
}
expect(message).toBeTruthy()
}) |
Basic functionality candidate. |
What? async function throws () {
throw new Error('hello world')
}
test('promise throws', async () => {
await expect(throws()).rejects.toThrow()
}) This is solved, please read the docs before commenting on old issues. https://jestjs.io/docs/en/asynchronous#resolves-rejects |
The important thing in the solution is to |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm trying to assert that a promise throws an error with Async / Await.
This is what I'm getting:
Any thoughts? Does Jest not support this? Or am I using it incorrectly?
The text was updated successfully, but these errors were encountered: