The selenium JS PageObjects sometime return a class constructor, and sometime return a new instance of that class.
example:
page.js returns a constructor
↓
edit.page.js extends the Page class and returns a new instance
↓
specs then require() that instance.
This is fine if the Page class is only being extended once, but we can't extend the classes any further after it returns an instance.
example of where this can be a problem (from this patch):
page.js returns a constructor
↓
minerva.page extends the Page class and returns a new instance
↓
minerva.mobile.page tries to extend that instance
↓
🚨ERROR: Class extends value #<MinervaMobilePage> is not a constructor or null🚨
It would be more consistent if all the pageobject classes returned a constructor instead of an instance all the time.
This would however, mean that we would have to change the way the pageobjects are require()'ed in the spec files.
Instead of just requiring the instance like UserLoginPage = require( '../pageobjects/userlogin.page' );
we would have to require the class and create a new instance as well.
Either like
UserLoginPage = new ( require( '../pageobjects/userlogin.page' ) )();
or
UserLoginPage = require( '../pageobjects/userlogin.page' );
userLoginPage = new UserLoginPage();
p.s.
(Looks like this could be related to T185094)