无法 运行 phantomJS on karma

Unable to run phantomJS on karma

我最近遇到了 PhantomJS 库的问题。

$ karma start

记录结果:

Karma v0.13.15 server started at http://localhost:9876/ Starting browser PhantomJS INFO [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Connected on socket H1vRWOIqgBCUjb_bAAAA with id 36694801 PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR TYPE_MISMATCH_ERR: DOM Exception 17: The type of an object was incompatible with the expected type of the parameter associated to the object. at /Users/farman/.../tests.webpack.js:122637 <- webpack:///~/crypto-browserify/rng.js:14:0

PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (2.21 secs / 0 secs)

模块版本:

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

crypto-browserify 库正在使用 Buffer,它是经过修改的 Uint8Array 缓冲区。 PhantonJS 显然有一个 bug 拒绝 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