QUnit&x2B;PhantomJS:asyncTest永远不会返回
我在尝试设置PhantomJS时遇到了一个问题,因此我可以通过Travis CI对我的JavaScript项目进行持续集成 基本上,即使是最简单的QUnit&x2B;PhantomJS:asyncTest永远不会返回,phantomjs,qunit,Phantomjs,Qunit,我在尝试设置PhantomJS时遇到了一个问题,因此我可以通过Travis CI对我的JavaScript项目进行持续集成 基本上,即使是最简单的asyncTest也不会返回。当使用节点或在浏览器(如Chrome)中测试时,它工作正常 我的asyncTest如下所示: asyncTest ("async test", function() { expect(1); console.log("Beginning test..."); setTimeout(function(
asyncTest
也不会返回。当使用节点
或在浏览器(如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);
});
我已经用最少的代码建立了一个存储库来重现问题:
我将感谢任何帮助 Salvatore
嘿。我发现问题出在qunit-logging.js中。当我从index.html中删除它时,测试运行良好
下面是我在phantomjs中运行qunit所做的\
- 我注释掉了qunit-logging.js引用李>
- 我从qunit树下载了runner.js插件:
- 我把它放在与主文件相同的目录中(在我的例子中,它是c:\temp\qunit\u test)
- 然后,我从命令行运行此命令:
Results:
Beginning test...
Test should now end...
Took 2045ms to run 1 tests. 1 passed, 0 failed.
此外,我还更新了从cdn运行的qunit源代码。我不知道您使用的是什么版本(我只能说是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>
测试套件
模块(“lib测试”);
异步测试(“异步测试”,函数(){
期望(1);
日志(“开始测试…”);
setTimeout(函数(){
start();
ok(真的,“真的是真的”);
log(“测试现在应该结束了…”);
}, 2000);
});
如果您使用的异步方法不是setTimeout
,它是否有效?就像回调函数一样简单?不,同样的问题。最初,我在使用回调函数的代码中发现了这个问题,但作为一个简单的示例,我使用了setTimeout
。