avajs / eslint-plugin-ava

ESLint rules for AVA
https://avajs.dev
MIT License
230 stars 49 forks source link

`t.throwsAsync()` and `t.notThrowsAsync()` should be awaited on #274

Closed novemberborn closed 4 years ago

novemberborn commented 5 years ago

Issuehunt badges

When you use the t.throwsAsync() and t.notThrowsAsync() assertion, you must await the promise they return. If the test function completes before the assertions do the test will fail.

We should add a rule to ensure users invoke these assertions with the await keyword. I'm not sure whether it should be recommended — you could assign the promise to a variable and await it later, but I don't think that's typical when you write tests.

See also the discussion in https://github.com/avajs/ava/issues/2245.

@sindresorhus?


Note: This issue has a bounty, so it's expected that you are an experienced programmer and that you give it your best effort if you intend to tackle this. Don't forget, if applicable, to add tests, docs (double-check for typos). And don't be sloppy. Review your own diff multiple times and try to find ways to improve and simplify your code. Instead of asking too many questions, present solutions. The point of an issue bounty is to reduce my workload, not give me more. Include a 🦄 in your PR description to indicate that you've read this. Thanks for helping out 🙌 - @sindresorhus


IssueHunt Summary ### Backers (Total: $60.00) - [issuehunt issuehunt](https://issuehunt.io/u/issuehunt) ($60.00) ### Submitted pull Requests - [#278 Add `use-t-throws-async-well` rule](https://issuehunt.io/r/avajs/eslint-plugin-ava/pull/278) --- #### [Become a backer now!](https://issuehunt.io/r/avajs/eslint-plugin-ava/issues/274) #### [Or submit a pull request to get the deposits!](https://issuehunt.io/r/avajs/eslint-plugin-ava/issues/274) ### Tips - Checkout the [Issuehunt explorer](https://issuehunt.io/r/avajs/eslint-plugin-ava/) to discover more funded issues. - Need some help from other developers? [Add your repositories](https://issuehunt.io/r/new) on IssueHunt to raise funds. --- IssueHunt has been backed by the following sponsors. [Become a sponsor](https://issuehunt.io/membership/members)
sindresorhus commented 5 years ago

I think it should be recommended.

issuehunt-oss[bot] commented 5 years ago

@issuehunt has funded $60.00 to this issue.