Karma - Chrome 失败 2 次(无法启动).放弃 [英] Karma - Chrome failed 2 times (cannot start). Giving up

查看:11
本文介绍了Karma - Chrome 失败 2 次(无法启动).放弃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 karma-chrome-launcher 运行我的测试,但是每次我运行我的测试时都会抛出这个错误:

I've been trying to run my tests using karma-chrome-launcher, but everytime I run my tests it throws this error:

INFO [launcher]: Starting browser Chrome
ERROR [launcher]: Cannot start Chrome
INFO [launcher]: Trying to start Chrome again (1/2).
ERROR [launcher]: Cannot start Chrome   
INFO [launcher]: Trying to start Chrome again (2/2).
ERROR [launcher]: Cannot start Chrome
ERROR [launcher]: Chrome failed 2 times (cannot start). Giving up.

这是我的 karma.conf.js 代码:

// Karma configuration
// Generated on Mon Mar 23 2015 14:04:19 GMT-0300 (BRT)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: 'www',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      'lib/ionic/js/angular/angular.js',
      'lib/ionic/js/angular/angular-animate.js',
      'lib/ionic/js/angular/angular-sanitize.js',

      '../node_modules/jasmine-core/lib/jasmine-core/jasmine.js',
      '../node_modules/mock-local-storage/lib/mock-localstorage.js',
      '../node_modules/angular-mocks/angular-mocks.js',
      //'../node_modules/requirejs/require.js',
      'lib/ionic/js/angular/angular-resource.js',
      'lib/ionic/js/angular-ui/angular-ui-router.js',
      'lib/ionic/js/ionic.js',
      'lib/ionic/js/ionic-angular.js',
      /*'../tests/libs/ngCordovaMocks.min.js',*/
      'js/lib/ng-cordova.min.js',
      'js/*.js',
      'js/controllers/*.js',
      'js/services/*.js',
      'js/factory/*.js',
      //'../tests/*.js',
      '../tests/**/*.js'
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress', 'html'],

    htmlReporter: {
      outputFile: '../tests/report/index.html'
    },


    // web server port
    port: 9876,

    plugins : [
      'karma-junit-reporter',
      'karma-jasmine',
      'karma-phantomjs-launcher',
      'karma-chrome-launcher'
      //'karma-htmlfile-reporter'
    ],

    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};

我在这里安装模块:https://www.npmjs.com/包/karma-chrome-launcher

谢谢!

推荐答案

我遇到了同样的问题并尝试了很多我找到的建议解决方案,但最终为我解决的是删除 node_modules 文件夹并通过 npm install 获取所有新内容.

I had the same problem and tried a lot of the suggested solutions I found, but what finally solved it for me was to delete the node_modules folder and getting everything new via npm install.

这篇关于Karma - Chrome 失败 2 次(无法启动).放弃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆