【发布时间】:2015-08-13 21:26:44
【问题描述】:
我正在使用node-phantom npm 模块,每当我做一个超级简单的测试时,比如
phantom=require('node-phantom');
var phantom=require('node-phantom');
phantom.create(function(err,ph) {
console.log("testing");
ph.exit();
});
它会打印以下错误:
phantom stdout: console msg:XMLHttpRequest cannot load http://127.0.0.1/socket.io/?EIO=3&transport=polling&t=1439501157936-0. Origin http://127.0.0.1:60689 is not allowed by Access-Control-Allow-Origin.
有人知道这是什么原因吗?
package.json:
{
"name": "test",
"version": "0.0.1",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-exec": "^0.4.6",
"mocha": "^2.2.5",
"node-phantom": "^0.2.5",
"phantom": "^0.7.2",
"phantomjs": "^1.9.18",
}
}
(幻影有多个版本,因为我一直在尝试)
【问题讨论】:
-
向我们展示 package.json 和你执行的命令
npm test? -
尝试phantom 而不是node-phantom。它具有基本相同的 API,但通信设置不同。顺便说一句,你在窗户上吗?
-
@EmilioPlatzer 我直接使用
node test.js运行脚本(我的文件名为test.js)。现在不尝试与测试套件绑定,实际上只是尝试设置我的环境并且没有任何工作。
标签: javascript node.js testing phantomjs