-
Notifications
You must be signed in to change notification settings - Fork 1.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
ES6 classes for commands #1199
Comments
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. |
There is a plan to write nightwatch in ES6, but that will take some time. Until then, I'm afraid we cannot support this. |
@senocular @beatfactor Sad but true. Thx for reply |
@beatfactor Just curious, is there any roadmap or update on when an ES6 class API might be available? I'd like to know because it would mean we could use TypeScript (ES6 classes + static typing). We can use TS now but the the compiler has a hard time following our code because of the behind-the-scenes magic that Nightwatch does. Cheers. |
Any update here? |
Any update? |
I wrote a small snippet that converts basic ES6 classes (test suites or page objects) to Nightwatch compatible objects. We just pass our ES6 classes through this function and get an object out the other end that we export for Nightwatch. Could this be useful for people in this thread? |
Here is the Gist for converting ES6 classes to Nightwatch compatible objects. It doesn't cover sections yet, but that should be a small change. It does require the class to be written in a specific way - if your classes look different then you can just modify it to fit that. There is a page object and a test suite example at the bottom of the gist to show how you need to structure your classes to export them with that function. Hope it can help someone! |
It has been a a year or more since last response. Any update on ES6 re-write? |
Still nothing? |
Hi, is it possible to use es6 classes for commands?
At the moment I got such error: Class constructor CreateHubCommand cannot be invoked without 'new'
Any plans to support this?
The text was updated successfully, but these errors were encountered: