Salvatore,
嘿。我发现问题在qunit-logging.js中。当我从index.html中删除它时,测试运行良好。
这里就是我所做的运行phantomjs内qunit。\
C:\ TEMP \ qunit_test> C:\幻象\ phantomjs.exe runner.js文件:/// C:/温度/ qunit_test /索引。 html
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>
如果您使用另一个异步方法比'setTimeout',它工作吗?就像回调函数一样简单? – Odi
不,同样的问题。最初,我在我的代码中发现了使用回调函数的问题,但是我使用'setTimeout'做了一个最小例子。 –