我为我的项目使用骨干样板并且在测试时遇到问题。对于测试,我使用QUnit。例如,测试集合:
测试/ index.html中
<html>
<head>
...qunit.js, qunit.css, other libraries...
<script data-main="../../app/config" src="../../vendor/js/libs/require.js"></script>
<!-- Declare your test files to be run here -->
<script>
QUnit.config.autostart = false;
// Ensure you point to where your tests are, base directory is app/, which
// is why ../test is necessary
require({
paths: {
tests: "../test/qunit/tests"
}
}, [
// Load the example tests, replace this and add your own tests
// "tests/example",
"tests/sites/collections"
], QUnit.start);
</script>
</head>
</html>
测试/位点/ collections.js
define(['modules/sites'], function (Sites) {
module("module sites collection", {
setup: function () {
this.collection = new Sites.Collection();
}
});
test("URL of sites collection.", function () {
expect(1);
equal(this.collection.url, 'http://bbb-example.x:8001/sites');
});
});
我在测试部分中的grunt.js文件看看:
qunit: {
all: ["test/qunit/*.html"]
},
当我打开浏览器窗口一切正常时,我看到了我的测试:
Tests completed in 385 milliseconds.
1 assertions of 1 passed, 0 failed.
但是当我尝试在控制台中运行它时,我看到了一个奇怪的错误:
~/projects/JS-bbb-example$ bbb test
Running "qunit:all" (qunit) task
Testing index.html
<WARN> PhantomJS timed out, possibly due to a missing QUnit start() call. Use --force to continue. </WARN>
Aborted due to warnings.
>> 0 assertions passed (0ms)
Done, but with warnings.
也许你知道这个问题,知道如何解决这个问题?谢谢你的帮助。