量角器angularJS全局变量

前端之家收集整理的这篇文章主要介绍了量角器angularJS全局变量前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用带有 angularjs的量角器来创建我的e2e测试.我有很多文件,我的specs数组很大,我想在所有文件中共享一个共同的功能.有没有办法创建一个全局的beforeEach,我可以注入我的函数
exports.config对象是否暴露了某些内容,以便我可以在所有文件中使用公共变量?
目前我正在躲避“浏览器”变量,但这可能是危险的.任何帮助深表感谢.谢谢

解决方法

是的,您可以使用量角器配置中的onPrepare()钩子轻松完成此操作:

exports.config = {
    // ...

    // 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() {
        // you can also add properties to globals here
    }
 };

猜你在找的Angularjs相关文章