javascriptangularjskarma-jasminetealium

How to set Tealium-Angular configuration in a karma test


There is a tagging library here: https://github.com/Tealium/integration-angularjs/blob/master/tealium_angular.js .

We integrated it into our application. During app initialisation we need to provide some configuration for this library. This is done like this:

Our app.js:

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

There is a karma test similar to this:

(function () {
    'use strict';

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

When I start the test, I get the following error coming from tealium_angular.js:

"account or profile value not set. Please configure Tealium first"

How can I set these config values in my karma test?


Solution

  • The solution was (my colleague Andrea Fűrész fixed it actually):

    She created a js file with the following content:

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

    Then in karma config it was added into the "files" configuration. Then it worked.