1

这里有一个标记库:https ://github.com/Tealium/integration-angularjs/blob/master/tealium_angular.js 。

我们将它集成到我们的应用程序中。在应用程序初始化期间,我们需要为此库提供一些配置。这样做是这样的:

我们的 app.js:

angular.module('appname', [ 'TealiumHelper' ])
.config(function (tealiumProvider) {
            tealiumProvider.setConfig({
                account: 'accountxx',
                profile: 'profilexx',
                environment: 'dev'
            });
        })

有一个类似这样的业力测试:

(function () {
    'use strict';

    describe('controllertest', function () {
        beforeEach(module('appname','TealiumHelper'));
        it('bla', function () {
            //test code
        }
    }
}

当我开始测试时,我收到来自tealium_angular.js的以下错误:

“未设置帐户或个人资料值。请先配置 Tealium”

如何在我的业力测试中设置这些配置值?

4

2 回答 2

1

在测试中,您可以为TealiumHelper模块提供自己的实现,例如

describe('controllertest', function () {

    beforeEach(module('appname'))

    angular.module('TealiumHelper', []).provider('tealium', {
        $get: function () {},
        setConfig: function () {}
    });

    /*** test starts here ***/
})
于 2017-01-31T16:48:03.697 回答
0

解决方案是(我的同事 Andrea Fűrész 实际修复了它):

她创建了一个 js 文件,内容如下:

function TealiumConfig() {
    'use strict';

    module('TealiumHelper', function (tealiumProvider) {
        tealiumProvider.setConfig({
            account: 'foooooo',
            profile: 'baaaar',
            environment: 'dev'
        })
    });
}

然后在业力配置中将其添加到“文件”配置中。然后它起作用了。

于 2017-02-13T08:35:23.210 回答