微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Angular 2,Karma和PhantomJS

我正在学习如何使用Angular 2设置Karma并遇到问题.

我按照Julie在她的seed project中所做的并将其应用到我的项目中.

一切都适用于Chrome,但当我想使用PhantomJS时,我收到错误.这也发生在PhantomJS2中……

这是错误

[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',{pattern : 'node_modules/es6-shim/es6-shim.js',{pattern : 'node_modules/angular2/bundles/angular2-polyfills.js',{pattern : 'node_modules/rxjs/bundles/Rx.js',{pattern : 'node_modules/angular2/bundles/angular2.js',{pattern : 'node_modules/angular2/bundles/testing.dev.js',{pattern : 'karma-test-shim.js',{pattern : 'app/**/*.js',included : false,{pattern : 'app/**/*.html',{pattern : 'app/**/*.css',{pattern : 'test/**/*.ts',watched : false},{pattern : 'test/**/*.js',{pattern : 'test/**/*.js.map',watched : false}

    ],proxies : {
        "/app/" : "/base/src/app/"
    },reporters : ['progress'],port : 9876,colors : true,logLevel : config.LOG_INFO,autoWatch : false,browsers : ['PhantomJS2'],singleRun : true
})}

谁知道我做错了什么?
提前致谢

确保你的karma.conf.js中的这一行
{pattern: 'node_modules/systemjs/dist/system-polyfills.js',included: false,watched: false},// PhantomJS2 (and possibly others) might require it

这个github项目使用幻像:

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

克隆它并玩一玩

原文地址:https://www.jb51.cc/angularjs/141160.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐