在尝试设置PhantomJS时,我遇到了一个问题,因此我可以通过Travis CI在我的JavaScript项目上进行持续集成。
基本上,即使是最简单的asyncTest也不会返回。在node或Chrome等浏览器上测试时,它工作得很好。
我的asyncTest看起来像这样:
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);
});我已经用最少的代码建立了一个存储库来重现这个问题:
https://github.com/siovene/phantomjs-async-test
如果有任何帮助,我将不胜感激!
发布于 2013-06-26 06:40:25
塞尔瓦托
嘿。我发现问题出在qunit-logging.js中。当我从你的index.html中删除它时,测试运行得很好。
下面是我在phantomjs中运行qunit的过程。
插件:https://github.com/jquery/qunit/tree/master/addons/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.此外,我还更新了qunit源代码,以便从cdn运行。我不知道你使用的是什么版本(我只能说是2012 ),我想用最新的版本来解决问题。下面是我的index.html文件:
<!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>https://stackoverflow.com/questions/15792315
复制相似问题