Javascript 基本测试中的PhantomJS错误
我正在使用node-phantom-npm模块,每当我做一个超级简单的测试,比如Javascript 基本测试中的PhantomJS错误,javascript,node.js,testing,phantomjs,Javascript,Node.js,Testing,Phantomjs,我正在使用node-phantom-npm模块,每当我做一个超级简单的测试,比如 phantom=require('node-phantom'); var phantom=require('node-phantom'); phantom.create(function(err,ph) { console.log("testing"); ph.exit(); }); 它将打印以下错误: 幻象标准输出:控制台消息:XMLHttpRequest无法加载http://127.0.0.1
phantom=require('node-phantom');
var phantom=require('node-phantom');
phantom.create(function(err,ph) {
console.log("testing");
ph.exit();
});
它将打印以下错误:
幻象标准输出:控制台消息:XMLHttpRequest无法加载http://127.0.0.1/socket.io/?EIO=3&transport=polling&t=1439501157936-0. 起源http://127.0.0.1:60689 访问控制允许原点不允许。
有人知道这是什么原因吗
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",
}
}
phantom有多个版本,因为我已经尝试了一些将node-phantom.js文件中的window.location.hostname更改为window.location.host。显示package.json和执行npm test的命令?请尝试,而不是。它的API基本相同,但通信设置不同。顺便问一下,你在windows上吗?@EmilioPlatzer我直接用node test.js运行脚本我的文件名为test.js。我现在不想和测试套件打交道,只是想把我的环境设置好,但什么都没用。谢谢,是的,我也找到了这个。这在技术上是可行的,但我希望有更好的方法。