Skip to content

🚀 Feature: Fatal error when async functions are passed to describe and context #4920

Open
@alcuadrado

Description

Is your feature request related to a problem or a nice-to-have?? Please describe.

I'm one of the maintainers of a popular tool that uses Mocha to run our users' tests. We get periodic reports about our tool not running any test (example), and in many cases, this is because the user is passing async functions to describe.

Describe the solution you'd like

I think throwing an error if executing the callback received by describe/context (I may be missing others) returns a Promise, explaining that the callback should be synchronous would be beneficial to Mocha's users.

Describe alternatives you've considered

For typescript users, we could partially achieve this by modifying @types/mocha so that the functions I mention stop accepting async functions, but that would be a partial solution, as not everyone uses typescript.

Additional context

This is a screenshot of a modified version of Mocha that behaves as proposed.

image

I can send a PR if there's interest in this feature.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions