So I can across this today and it might already have been answered somewhere but I'm curious why this isn't picking up all classes with the same name. So I have two requires from two different classes of two different areas of testing that have the same name.
Const AreaOneLoginPage = require('../../pages/areaOne/login.page');
Const areaOneLoginIn = new AreaOneLoginPage();
Const AreaTwoLoginPage = require('../../pages/areaTwo/login.page');
Const areaTwoLoginIn = new AreaTwoLoginPage ();
However when I try to construct this in a different way using the smart logic in Visual Studio Code. This always defaults to AreaOne.
Const areaOneLogin = new LoginPage(); //<== This is the class name of the first area.
Const areaTwoLogin = new LoginPage(); //<== This is the class name of the second area.
The only option Visual Studio picks up is AreaOne and not show all the Classes that link into LoginPage??
Is this just a Visual Studio thing that can be fixed or is this a javascript thing?
Or is it best to refactor the class names to two different names completely. I just figured that VS Code would be able to determine that the class is nested below a seperate folder location?
You can import the one module in one file many times, if they will be named unique. And then you can create new objects from these classes/modules.
To prevent this we have Singleton Pattern. it saves the instance of itself and if there was the init earlier, you will get the instance of exsisting object instead of creating new one.
Hope this was the answer to your question