-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Interface changes for support code #770
Comments
@nicojs sorry for the delayed response
This was an easy transition from the original 1.0 interface as it dealt with functions and just moved the functions from this to the first argument. I cared most about stopping the library from calling all exported functions.
I'm okay with this if you'd like to take a stab. I believe the easiest way this could be implemented while retaining the current interface as well is const {Given} = require('cucumber');
Given(...)
// is basically syntactic sugar for
defineSupportCode(({Given}) => {
Given(...)
})
See #745 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm very happy with the interface changes done using issue #679 However, i still think its a little verbose and there is some room for improvement. I want to improve on that further.
Right now, a step definition file looks like this:
The way i see it, there are 2 things that could be better.
First there is some very specific boilerplate code needed with the
defineSupportCode
. This is illustrated best with the({ Given, When, Then })
part. Its an eye sore. I understand you're using parameter context matching here, but it's not that well known as an ES feature.Second, there is the
this
redirection for the world object. If i write my code examples with arrow functions instead of using thefunction
keyword, bad things could happen because I'm leaking state. But this particular test will still succeed. This can be very confusing.The first issue could be solved by requiring
Given
,When
andThen
directly form'cucumber'
. Is there a reason for thedefineSupportCode
construct?The second issue is a little bit harder to solve without much clutter. But i still would like to improve the api. Any thoughts on this?
Background: I give automated testing courses to testers and i see they have a some trouble understanding concepts like
this
redirection and functional programming. I would like to improve their lives with the 2.0 api.The text was updated successfully, but these errors were encountered: