I could not find how to remove code duplication in Javascript (basically what I would achieve in Java with base classes).
A specific example is (at least) the following code, which is common to all specification files (and potentially page objects, since I am testing this template in protractor):
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
var expect = chai.expect;
Can I do something that can be expected everywhere? I tried in the protractor configuration to upload a file with this parameter:
specs: [
'e2e/helpers/commonDefinitions.js',
'e2e/**/*.spec.js'
]
or use beforeLaunch or onPrepare (but want a function not sure how to set vars this way), but without success.
However, I would prefer to use a generic Javascript approach to reusing this type.
- , (, , )?