question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rule to enforce returning promise in async tests instead of done

See original GitHub issue

don’t know if it is possible to enforce usage of promise returns, probably not. at least it should be possible to check that done argument is not used and a return something is used instead

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
lo1tumacommented, Jun 1, 2016

Ok, sounds like it is a stylistic rule.I think we can do this by simply looking for the done argument and warn whenever it is specified. Checking if the return statement is present could be covered by #5.

1reaction
jfmengelscommented, Jul 27, 2016

Anyway, now that I have found a solution, I’m all for this rule, but the documentation should probably give tips on how to achieve this (normal case and my expected error case).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async and Await in JavaScript, the extension to a promise.
An async function simply implies that a promise will be returned and if a promise is not returned, JavaScript will automatically wrap it...
Read more >
For async tests and hooks, ensure "done()" is called
For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. Now consider this slightly different test, ...
Read more >
Testing-library: avoid these mistakes in async tests
Never forget to await for async functions or return promises from the test (jest will wait for this promise to be resolved in...
Read more >
New rule: enforce async/await consistency #9787 - GitHub
Enforce that all functons that are being awaited be marked as async. Prohibit awaiting functions that are not returning pr...
Read more >
Understanding the Event Loop, Callbacks, Promises, and ...
When an asynchronous Web API is used, the rules become more ... will execute the callback after the asynchronous action has completed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found