I've run into a problem when trying to setup PhantomJS, so I could do continuous integration on my JavaScript project via Travis CI.
Basically, even the simplest asyncTest
just never returns. It works fine when tested with node
or in a browser, like Chrome.
My asyncTest
looks like this:
asyncTest ("async test", function() {
expect(1);
console.log("Beginning test...");
setTimeout(function() {
ok(true, "true is true");
start();
console.log("Test should now end...");
}, 200);
});
I've set up a repository with the minimal code to reproduce the problem:
https://github.com/siovene/phantomjs-async-test
I'd appreciate any help!
Salvatore,
Hey. I found the problem to be within the qunit-logging.js. When I removed that from your index.html, the tests ran fine.
Here's what I did to run the qunit within phantomjs.\
C:\temp\qunit_test>c:\phantom\phantomjs.exe runner.js file:///c:/temp/qunit_test/index.html
Results:
Beginning test...
Test should now end...
Took 2045ms to run 1 tests. 1 passed, 0 failed.
Also, I did update the qunit sources to run from the cdn. I couldn't tell what version you were using (it's from 2012 is all I could tell), and I wanted to troubleshoot with the latest version. So here's my index.html file:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test Suite</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<!-- qunit -->
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css" type="text/css" media="screen" />
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<!--<script src="qunit-logging.js"></script>-->
<script type='text/javascript'>
module("lib-test");
asyncTest ("async test", function() {
expect(1);
console.log("Beginning test...");
setTimeout(function() {
start();
ok(true, "true is true");
console.log("Test should now end...");
}, 2000);
});
</script>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With