ES6 classes for commands #1199

Closed
satispunk opened this Issue Sep 26, 2016 · 3 comments

Projects

None yet

3 participants

@satispunk

Hi, is it possible to use es6 classes for commands?

modules.exports = class CustomCommand() {
    command() {
   }
}

At the moment I got such error: Class constructor CreateHubCommand cannot be invoked without 'new'

Any plans to support this?

@senocular
Contributor
senocular commented Sep 26, 2016 edited

Nightwatch is written in ES5 and uses ES5-style class definitions to implement custom command classes. This involves subclassing custom commands and calling their constructors for super on the subclass. Because ES6 does not allow callable constructors, they are not compatible with this approach. Basically its the problem of:

class SuperClass {} // ES6

function SubClass () { // ES5
    SuperClass.call(this); // equiv of super()
}

new SubClass(); // constructor err

So to answer your first question: No, this isn't currently supported. I also doubt there's any pre-existing plan to change that, but that's what these issues are for.

@beatfactor
Member

There is a plan to write nightwatch in ES6, but that will take some time. Until then, I'm afraid we cannot support this.

@beatfactor beatfactor closed this Sep 26, 2016
@satispunk

@senocular @beatfactor Sad but true. Thx for reply

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