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'做了一個最小例子。 –