phantomjs和run-jasmine.js超时

tko*_*one 6 javascript unit-testing jasmine phantomjs

所以我有一个奇怪的问题.

我在本地机器上运行了本地运行的Jasmine测试运行器:localhost:8080/test/runner.html

当我在网络浏览器中打开它时,它可以很好地工作.

我想自动化这个,所以我使用phantomjs(从brew安装 - 我在Mac上),我正在使用代码中的示例run-jasmine.js文件.

但是,每当我针对URL运行它,我得到这个:

phantomjs war/test/spec/run_jasmine.js http://localhost:8080/test/runner.html
'waitFor()' timeout
Run Code Online (Sandbox Code Playgroud)

所以我写了一个非常简单的脚本来查看是否有我遗漏的东西:

var page = require('webpage').create();

page.open(phantom.args[0],
function(status) {
    if (status !== "success") {
        console.log("Unable to access network");
        phantom.exit();
    } else {
        if (document.body.querySelector('#hello')) {
            console.log('hi');
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

并创建了一个新的HTML文件:

<!DOCTYPE html>
<html>
<head>
    <title>hi</title>
</head>
<body>
    <div id="hi"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

而事情仍然永远挂起.

我在这里错过了什么吗?我知道页面正在加载,但它看起来并不像是phantomjs正在解析它.

tko*_*one 5

好吧,我觉得愚蠢.

/ test /需要身份验证.