Unit testing

Has anyone incorporated or know how to incorporate unit testing with or without using a framework (such as Mocha.js, Jasmine, QUnit etc.) for utag.js and/or extensions/tags created in Tealium? 

Accepted Solutions (1)

Accepted Solutions (1)

A few tips for testing tags:

  1. Delay test start until third party libraries and api calls have loaded.
  2. URLs from successful script, iframe and pixel requests can be viewed in chrome browsers using getNetworkResources(). This will include data passed via query string parameters that can be verified against your data layer.
  3. To view the log from utag.js, set the utagdb cookie to true before page load document.cookie = “utagdb=true”;. utag.db_log will then contain information whether or not a tag or extension fired. (e.g. 1234: Tag not fired: Required attribute “account_id” not populated)

An example of using Mocha.js and Chai.js to test whether your tag library was loaded:

it("Should load library.js", function() {
const urls = getNetworkResources().filter(url => {return url.includes("library.js")});


Tealium Employee

Answers (0)

Ask a Question
Top Kudoed Authors