Problem:
I am using zombie.js to test my client side javascript, but I have a problem. Zombie.js does not provide synchronous execution of the <script>
and, apparently, does not execute external JS files at all. A basic test confirms this:
<script type="text/javascript" src="test1.js"></script> <script type="text/javascript" src="test2.js"></script> <script type="text/javascript" src="test3.js"></script> <script type="text/javascript"> console.log("Inline javascript."); </script>
Each test # .js contains one line: console.log("TEST#.JS");
When I do this in a normal browser, the console displays the expected:
TEST1.JS TEST2.JS TEST3.JS Inline javascript.
But when I run it with zombie.js, I see only one line of Inline javascript.
Here I tried to work around the problem:
- using
document.createElement
to dynamically add a script tag to a document - using
document.write
to add a script block to html - using
setTimeout
on console.log("Inline javascript")
in combination with 1 and 2 to give test scripts some time to load.
Is there a way to solve this problem besides placing JS code from all my external JS files in a huge <script>
block?
laker source share