I have been trying my hands on creating a custom template tag, like so:
// Require the necessary APIs
const logToConsole = require('logToConsole');
const injectScript = require('injectScript');
// construct URL
const url = "https://www.dwin1.com/" + data.merchantId + '.js';
// If the user chose to log debug output, initialize the logging method
const log = data.debug ? logToConsole : (() => {});
log('AWIN: Loading script from ' + url);
// If the script loaded successfully, log a message and signal success
const onSuccess = () => {
log('AWIN: Script loaded successfully.');
data.gtmOnSuccess();
};
// If the script fails to load, log a message and signal failure
const onFailure = () => {
log('AWIN: Script load failed.');
data.gtmOnFailure();
};
injectScript(url, onSuccess, onFailure, url);
URL Pattern match: https://www.dwin1.com/
but when I now try to run a test like so
const mockData = {
merchantId: 1001,
debug: true
};
// Call runCode to run the template's code.
runCode(mockData);
// Verify that the tag finished successfully.
assertApi('gtmOnSuccess').wasCalled();
Hey even I faced the same issue, but as I debugged it was due to AdBlocker which was blocking the script, you need to allow it and check if you have any AdBlocker installed on your machine.