【问题标题】:Unable to run phantomJS on karma无法在业力上运行 phantomJS
【发布时间】:2016-02-13 08:41:29
【问题描述】:

我最近在使用 PhantomJS 库时遇到了问题。

$ karma start

日志结果:

Karma v0.13.15 服务器开始于http://localhost:9876/ 开始 浏览器 PhantomJS 信息 [PhantomJS 1.9.8 (Mac OS X 0.0.0)]:已连接 在套接字 H1vRWOIqgBCUjb_bAAAA 上,ID 为 36694801 PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR TYPE_MISMATCH_ERR: DOM Exception 17: The type of an object is not compatible with the expected 与对象关联的参数的类型。在 /Users/farman/.../tests.webpack.js:122637

PhantomJS 1.9.8 (Mac OS X 0.0.0):执行 0 of 0 错误 (2.21 秒 / 0 秒)

模块版本:

  • OSX:埃尔卡皮坦 10.11.1
  • 节点:5.0.0
  • 业力:0.13.15
  • karma-phantomjs-launcher:0.2.1
  • Phantomjs:1.9.18

我已经检查了论坛,但仍然没有解决问题: https://github.com/AngularClass/angular2-webpack-starter/issues/45

【问题讨论】:

  • 最近更新了一些依赖项后,在 React 应用程序中看到了同样的错误。 (仅提及这一点是为了指出它可能与 Angular 无关。)
  • 看起来crypto-browserify/rng.js 指出了可能的原因:“这不适用于旧版浏览器”(我假设包括 PhantomJS- 除非您对其进行填充)
  • 可以验证修补此功能以使用 Math.random 确实解决了我在 PhantomJS 中的问题,但这并不是一个真正可行的解决方案。
  • 看起来更新crypto-browserify/rng.js 以使用Uint8Array 而不是Buffer 也解决了错误(至少在我的初始测试中)

标签: karma-runner


【解决方案1】:

crypto-browserify 库正在使用Buffer,它是缓冲区是修改后的Uint8Array。 PhantonJS 显然有一个错误,它拒绝 Buffer,这导致了您看到的问题。

我在这里提出了一个问题: https://github.com/crypto-browserify/crypto-browserify/issues/143

您也可以通过更新 crypto-browserify/rng.js 来临时修补此问题...

var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array

...用这个...

var bytes = new Uint8Array(size); //in browserify, this is an extended Uint8Array

【讨论】:

    猜你喜欢
    • 2014-02-24
    • 2014-05-24
    • 1970-01-01
    • 2018-01-28
    • 1970-01-01
    • 1970-01-01
    • 2011-11-17
    • 2016-08-21
    • 1970-01-01
    相关资源
    最近更新 更多