I\'m trying to import an AMD module (ES6 module transpiled in ES5) in a protractor test. I\'m using the Page Object pattern. And the Page Object is the module I\'m trying to
A solution is to use amdefine as it is described in requirejs.org/docs/node.html#3 the drawback of this solution is that you need to prepend every module by the following line :
if (typeof define !== 'function') { var define = require('amdefine')(module) }
In my specific case, because I'm using traceur to transpile ES6 files, I chose to use commonjs module instead of AMD for e2e tests. The reason it's different from unit tests executed by Karma (where I can easily use AMD) is the fact that protractor tests are executed by Node.js and not by the browser. So, I changed the traceur modules options for e2e tests only to this:
{
"modules": "commonjs",
"script": false,
"types": true,
"annotations": true,
"memberVariables":true,
"outputLanguage": "es5"
}