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.

Feature request: UI that does not use the `this` keyword

See original GitHub issue

Given 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:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
charlierudolphcommented, Feb 15, 2017

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?

defineSupportCode(({setWorldInjectionStrategy}) => {
  setWorldInjectionStrategy('this') // default
  setWorldInjectionStrategy('argument') // makes world be the first argument to steps and hooks 
})
2reactions
armandabriccommented, May 12, 2017

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 that

For 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.

Read more comments on GitHub >

github_iconTop 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 >

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