This provides a function to fix issues seen in the tests for various integrations caused by a race between scripts that an integration loads and the test framework.
This was tested against the adroll and route integrations, which have been failing spuriously due to this race condition.
It overrides the document.createElement method in order to track all dynamically created script tags. A map (waiting) is kept of all elements who have not yet loaded, which are removed from this map once the load event fires. Once the last removal happens, it will callback everyone waiting for scripts to load.
This provides a function to fix issues seen in the tests for various integrations caused by a race between scripts that an integration loads and the test framework.
This was tested against the adroll and route integrations, which have been failing spuriously due to this race condition.
It overrides the
document.createElement
method in order to track all dynamically createdscript
tags. A map (waiting
) is kept of all elements who have not yet loaded, which are removed from this map once theload
event fires. Once the last removal happens, it will callback everyone waiting for scripts to load.