基本测试时出现PhantomJS错误

时间:2015-08-13 21:26:44

标签: 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();
});

它会输出以下错误: 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",
  }
}

(有多个版本的幻影,因为我一直在尝试一些)

1 个答案:

答案 0 :(得分:4)

window.location.hostname文件中将window.location.host更改为node-phantom.js