Nodejs > Same Class imported at two different class - recognized at one class and not recognized at another

197
December 08, 2017, at 10:21 AM

Project Background: Technology: NodeJs, Webdriverio, Mocha, Chai, (configured ECMA6 in IDE) —————— File: product-page.js

var/let Component = require(‘./component.js’);
Class ProductPage{
    constructor(productType){
        this. productType = productType;
    }
    getFirstProduct(){
        return new Component(first);
    }
}
module.exports = {
    ProdPage : function(pType){
        if(pType === "type"){
            return new ProductPage(type);
        }else {
            return new ProductPage();
        }
    }
};

—————— File: component.js

var/let ProductPage = require(‘./product-page.js’). ProdPage;
Component(){
    constructor(comp){
        this.comp = comp;
    }
    action(){ //some action; return this; }
    clickToListProducts(type){
        return new ProductPage(aType); // This line does not returns ProdutPage, Error: ProductPage is not a function
    }
}
module.exports = Component;

—————— File: sample.js

var/let ProductPage = require(‘./product-page.js’). ProdPage;
SampleTest(){
    describe(){
     it(){
        SignInPage.signin();
        ProductPage()
            . getFirstProduct(first)
            .action()
            . clickToListProducts(sometype) // receives error from component page
    }
    }
}

——————

Here Product Page imported at SampleTest class works fine, But Product Page imported at Component is not recognized.

But following code works fine, hence i confirmed ProductPage accepts both no-arguments and single arguments

 it(){
    SignInPage.signin();
    ProductPage()
        . getFirstProduct(first)
        .action()
    ProductPage(sometype) // works fine
}

I have tried different combination of exporting and importing, but could not find solution.

Rent Charter Buses Company
READ ALSO
Using require with node_modules

Using require with node_modules

I've been trying to wrap my head around this issue, and have not come any closer to solving it in the past 24 hours

221
GCM XMPP Socket consistently getting EPIPE and disconnected when sending notifications

GCM XMPP Socket consistently getting EPIPE and disconnected when sending notifications

We have an xmpp connection server that connects sockets to GCM XMPP endpoints and starts sending notifications

331
How to deploy node app on openshift and run it?

How to deploy node app on openshift and run it?

Just created a very simple hello world app using node:

251
Npm 5.5 shrinkwrap or yarn vs packaging node_modules to production

Npm 5.5 shrinkwrap or yarn vs packaging node_modules to production

First, I know this question has been asked many many times before, but all those questions goes back to 2014, 2015 or before

198