How to import a javascript class and extend it in another script unit
Hi I am trying to use two Javascript projects - and export a class defined in one to be extended (inherited) in another. The example herehttps://community.smartbear.com/t5/TestComplete-General-Discussions/how-to-import-a-javascript-class/m-p/149161#M27448 shows how to use require and create an instance of the class. However, I would like to inherit the class (ES6) and define or override the methods. I was able to do this using prototype based inheritance (ES3). But unable to do this using ES6 terms. The "import" keyword usage shows syntax error "Unexpected token import". If I use require, then I cannot actually use it with extends e.g. (Note that I have shared the Parent.js into the project) //In Parent.js class ParentApp { constructor(x) { this.name = x; } } module.exports = { ParentApp: ParentApp } //In Child.js var parent = require("Parent") class Child extends parent.ParentApp { constructor(y, z) { super(y); this.age = z; } } Here the "parent.Parent" is not working. And I can't use import keyword. (Note that sometimes having the script name same as class name seems to cause issues and that's why I use Parent and ParentApp to differentiate) So how do I do this? Is ES6 fully suppported in Test Complete 14?Solved16KViews0likes6Comments