-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
🚀 Feature: New interface to support arrow functions #2657
Comments
Forcing the function to be async to enable people to access the context seems like a pretty annoying API. I still have no clue why people want to use arrow functions when it explicitly does the wrong thing in mochas context |
Came here for this, but I've also found https://github.com/skozin/arrow-mocha |
Here is a version which can work with mocha's |
@alexreardon thanks for the suggestion, You can always do the following as well:
|
Replacing the default It's possible to create an interface which passes the context as the first parameter, but would likely require modifications to Mocha's core to support, due to hardcoded assumptions. Would accept a PR that would allow the "async check" of an interface to be configurable. Once that's ready, then it should be fairly trivial to provide an alternate interface. |
What does it mean? I think this feature could be implemented in 2 ways:
|
Yeah, this would be a pretty big change to Mocha that is already solved by at least one userland integration mentioned in this thread. Per #5027 we're not looking to do big shakeups any time soon. |
Currently functions that use
() =>
cannot take advantage of the mocha context: http://mochajs.org/#arrow-functions.However, arrow function usage could be improved by passing the context as an argument:
The complicating factor is the
done
argument. The presence of which makes the test async. Perhaps if you want to use thecontext
argument then you need to also calldone
when appropriate.The text was updated successfully, but these errors were encountered: