How to setup protractor to import AMD modules with requirejs

后端 未结 3 341
天涯浪人
天涯浪人 2021-01-14 14:01

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

3条回答
  •  花落未央
    2021-01-14 14:41

    You can also use amdefine as said Martin, but without prepending each file with
    if (typeof define !== 'function') { var define = require('amdefine')(module) }

    Just include "amdefine": ">=0.1.0" in your devDependencies and add require('amdefine/intercept'); to onPrepare function in your protractor config. It will automatically insert the above snippet in each .js file loaded by Node.

提交回复
热议问题