Feature request: UI that does not use the `this` keyword
See original GitHub issueGiven a world such as:
require('cucumber').defineSupportCode( ({setWorldConstructor:world}) => {
world(class {
constructor(p) { ... }
foo(bar) { return new Promise(.... ) }
})
})
I want to be able to write:
When(/^I do the foo with (.*)$/i, (ctx, bar) => ctx.foo(bar) );
instead of
When(/^I do the foo with (.*)$/i, function(bar) {
return this.foo(bar)
});
This will also rid me from monkeying the .bind(this)
on all async operations, or if you prefer - rid of monkeying with var that = this
.
One more benefit (IMHO)- it will help people get off inheritance tree for worlds and orient them better towards the better powers of JS
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:17 (8 by maintainers)
Top Results From Across the Web
Allow User to Search for Keywords - Feature Requests - Emby ...
The aim of this is the allow the user to correct any problem using the Emby UI instead of having to go other...
Read more >15 Feature Request Tools for Managing Product Feedback
A feature request tool is a platform that collects product feedback and suggestions from customers.
Read more >How to Collect and Manage Feature Requests in SaaS
In this article, we'll cover several methods for collecting and managing feature requests to meet customer expectations for your SaaS.
Read more >TestComplete Feature Requests - SmartBear Community
Welcome to the TestComplete Feature Requests board! Here you can review submitted feature requests and vote up the ones you like! If you...
Read more >Wikipedia:Ignored feature requests
The village pump is crowded, and is explicitly not for the requesting of new features. Use MediaZilla or the correct meta page instead....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay. As not everyone is a functional programmer though and to prevent the introduction of a breaking change, what do you guys think of making an option which makes the world be passed as the first parameter?
I totally agree with the idea to inject the world/context has a parameter of the step. Starting by this project, all the JS ecosystem is moving to fully embrace the new functionalities allowed by ES6 and that’s a good things ❤️
If you look on other tools like Express or Koa, they set the current request context as the
this
AND as first parameter of the middleware (it is the equivalent of cucumber step). This solution allow traditional use of function and the use of ES6 arrow function. Another advantage of the context in as the first parameter is thatFor the solution proposed by @charlierudolph, I do not think this could works on a long run: this will split the community in two. All cucumber examples will not be working in all installations and the docs will be duplicated in two. Not fancy.
I’m not sure about the breaking change worries, the v2 is the perfect time to introduce this kind of change. Waiting will force to make/wait for another major.