【发布时间】:2016-06-10 16:00:40
【问题描述】:
我试图在本地量角器配置中的 onPrepare 方法中调用自定义函数,该函数扩展了全局量角器配置,但无法使其工作。为了让它更简单一点,我在 protractor.config 中这样写了它
module.exports = {
foo: function() {
console.log('testing');
},
// A callback function called once protractor is ready and available, and
// before the specs are executed
// You can specify a file containing code to run by setting onPrepare to
// the filename string.
onPrepare: function() {
// At this point, global 'protractor' object will be set up, and jasmine
// will be available. For example, you can add a Jasmine reporter with:
// jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
// 'outputdir/', true, true));
console.log(foo);
},
};
我的 local.protractor.config 是
var globalConf = require('./protractor.conf.js');
exports.config = globalConf;
但我收到错误,因为 foo 未定义。
[launcher] Error: ReferenceError: foo is not defined
有没有办法添加 onprepare 可以调用的自定义方法,我可以在 local.protractor.config 中调用它
【问题讨论】:
标签: javascript protractor