2016-04-06 16 views
7

私は角度2でカルマをセットアップし、問題にぶつかる方法を学んでいます。Angular 2、Karma and PhantomJS

私はジュリーが彼女のseed projectで行ったことに従って、私のプロジェクトにそれを適用しました。

Chromeでうまく動作しますが、PhantomJSを使用するときにエラーが発生します。

[karma]: Karma v0.13.22 server started at http://localhost:9877/ 
[launcher]: Starting browser PhantomJS2 
[PhantomJS 2.0.0 (Mac OS X 0.0.0)]: Connected on socket /#1yDrSei5NUX4_WYaAAAA with id 93476222 
Missing error handler on `socket`. 
TypeError: (msg || "").replace is not a function 
    at node_modules/karma/lib/reporter.js:45:23 

karma.config.js

module.exports = function (config) { 
config.set({ 
    basePath : '', 
    frameworks : ['jasmine'], 
    files : [ 
     // paths loaded by Karma 
     {pattern : 'node_modules/systemjs/dist/system-polyfills.js', included : true, watched : true}, 
     {pattern : 'node_modules/systemjs/dist/system.src.js', included : true, watched : true}, 
     {pattern : 'node_modules/es6-shim/es6-shim.js', included : true, watched : true}, 
     {pattern : 'node_modules/angular2/bundles/angular2-polyfills.js', included : true, watched : true}, 
     {pattern : 'node_modules/rxjs/bundles/Rx.js', included : true, watched : true}, 
     {pattern : 'node_modules/angular2/bundles/angular2.js', included : true, watched : true}, 
     {pattern : 'node_modules/angular2/bundles/testing.dev.js', included : true, watched : true}, 

     {pattern : 'karma-test-shim.js', included : true, watched : true}, 
     {pattern : 'app/**/*.js', included : false, watched : true}, 

     {pattern : 'app/**/*.html', included : false, watched : true}, 
     {pattern : 'app/**/*.css', included : false, watched : true}, 

     {pattern : 'test/**/*.ts', included : false, watched : false}, 
     {pattern : 'test/**/*.js', included : false, watched : true}, 
     {pattern : 'test/**/*.js.map', included : false, watched : false} 

    ], 

    proxies : { 
     "/app/" : "/base/src/app/" 
    }, 

    reporters : ['progress'], 
    port : 9876, 
    colors : true, 
    logLevel : config.LOG_INFO, 
    autoWatch : false, 
    browsers : ['PhantomJS2'], 
    singleRun : true 
})} 

誰もが私が間違っているのか知っている:これはまた

この

は誤りである... PhantomJS2になりますか?事前

+0

を持っていますこれは役に立ちますか? http://stackoverflow.com/a/36133360/771848 – alecxe

+0

ありがとうalecxeしかし、私のrxは適切なケースですRxと私はシムのインポートを変更しようとしました。 – Thibs

+0

https://github.com/karma-runner/karma/issues/1969 –

答えて

0

で おかげで、このgithubのプロジェクトはファントムと連携

{pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false}, // PhantomJS2 (and possibly others) might require it 

あなたkarma.conf.jsにこの行を確認してください。

https://github.com/danday74/angular2-coverage/blob/master/karma.conf.js

クローンをそれと遊び

関連する問題