Protractor addMockModule additional arguments not working?

烂漫一生 提交于 2019-12-06 04:38:14

Appearantely the args should be passed as array. This is how it worked for me:

        var test =  {
            val1: 'val1',
            val2: 'val2'
        };
       browser.addMockModule('mockModule', function( args) {
            angular.module('mockModule', [])
                .value('TEST', args[0]);

        }, [test]);

This works for me:

var mock = function(args) {
    // args.apiBase should be available here
    var env = args;
    var mocks = angular.module('mocks.login', ['MyApp', 'ngMockE2E']);
    mocks.run(function($httpBackend) {
        $httpBackend.whenGET(env.apiBase + '/companies').respond([]);
    });
};

browser.addMockModule('mocks.login', mock, {apiBase: ""});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!