Skip to content
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

Allow for asserting throws on async methods #4384

Closed
wants to merge 10 commits into from

Conversation

mcgear
Copy link

@mcgear mcgear commented Feb 25, 2024

We ran into a use case where we need to be able to assert throws from an async function. I was unable to figure out how to do this with existing assert throws, so added this implementation.

@mcgear mcgear requested a review from kt3k as a code owner February 25, 2024 08:26
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@aapoalas
Copy link
Collaborator

You're probably looking for assertRejects

@iuioiua
Copy link
Contributor

iuioiua commented Feb 25, 2024

Aapo is right. See https://deno.land/std/assert/mod.ts?s=assertRejects

Perhaps we should mention the related asynchronous or synchronous function in each of the functions JSDocs. This isn't the first time someone hasn't realised one of these assertion functions exists.

@iuioiua
Copy link
Contributor

iuioiua commented Feb 25, 2024

@mcgear, please see the comments above.

@kt3k
Copy link
Member

kt3k commented Feb 26, 2024

Perhaps we should mention the related asynchronous or synchronous function in each of the functions JSDocs. This isn't the first time someone hasn't realised one of these assertion functions exists.

Sounds good. Let's mention assertRejects in the doc of assertThrows

@mcgear
Copy link
Author

mcgear commented Feb 28, 2024

This seems to have worked just fine, closing the PR.

@mcgear mcgear closed this Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants