Shruti Nair
Shruti Nair

Reputation: 2034

karma chrome not loading.its giving up after two attempts

I'm integrating Jasmine and karma for unit testing my ionic app. I'm following this blog.

When i run the karma start command i keep getting this result.

23 02 2017 16:39:18.508:WARN [karma]: No captured browser, open 23 02 2017 16:39:18.517:INFO [karma]: Karma v1.5.0 server started at http://0.0.0.0:9876/ 23 02 2017 16:39:18.517:INFO [launcher]: Launching browser Chrome with unlimited concurrency 23 02 2017 16:39:18.536:INFO [launcher]: Starting browser Chrome 23 02 2017 16:40:18.537:WARN [launcher]: Chrome have not captured in 60000 ms, killing. 23 02 2017 16:40:18.910:INFO [launcher]: Trying to start Chrome again (1/2). 23 02 2017 16:41:18.911:WARN [launcher]: Chrome have not captured in 60000 ms, killing. 23 02 2017 16:41:19.357:INFO [launcher]: Trying to start Chrome again (2/2).

Tried with PhantomJS also

Same error

Launching browser PhantomJS with unlimited concurrency 23 02 2017 17:44:30.214:INFO [launcher]: Starting browser PhantomJS

23 02 2017 17:45:30.215:WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.

23 02 2017 17:45:30.238:INFO [launcher]: Trying to start PhantomJS again (1/2). 23 02 2017 17:46:30.239:WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.

23 02 2017 17:46:30.246:INFO [launcher]: Trying to start PhantomJS again (2/2).

23 02 2017 17:47:30.247:WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.

23 02 2017 17:47:30.254:ERROR [launcher]: PhantomJS failed 2 times (timeout). Giving up.

Config

// Karma configuration
// Generated on Thu Feb 23 2017 10:39:27 GMT+0530 (IST)

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

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


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


    // list of files / patterns to load in the browser
    files: [
      '../www/lib/ionic/js/ionic.bundle.js',
      '../www/js/**/*.js',
      '../tests/unit-tests/**/*.js',
      '../node_modules/angular-mocks/angular-mocks.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'],


    // web server port
    port: 9876,


    // 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'],
   browsers: ['Chrome'],
    // customLaunchers: {
    //   Chrome_no_sandbox: {
    //     base: 'Chrome',
    //     flags: ['--no-sandbox']
    //   }
    // },
     plugins:[
             'karma-jasmine',
             'karma-phantomjs-launcher',
             'karma-chrome-launcher'
             ],
    




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


    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity,
    
  })
}

Please help

Thanks!

Upvotes: 2

Views: 5900

Answers (3)

Yevheniy Potupa
Yevheniy Potupa

Reputation: 577

Try increasing browserDisconnectTolerance. Reasons could be different, from the wrong path in karma.config to some flaky npm run.

Upvotes: 0

pasi
pasi

Reputation: 11

This is the top Google result for this question, so even though it's old I hope my answer helps someone.

In our case the issue was caused by multiple files importing from the wrong library. This seems strange since you would think that Karma would throw an error rather than just refusing to open Chrome, but altering our import statements got us past the issue.

import { ChangeDetectionStrategy } from "@angular/core";

NOT AS OUR FILES HAD IT: import { ChangeDetectionStrategy } from "@angular/compiler/src/core";

Upvotes: 1

faizal vasaya
faizal vasaya

Reputation: 492

This says you should try add the below code to karma.conf.js file:

browsers: ['Chrome_no_sandbox'],
    customLaunchers: {
      Chrome_no_sandbox: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    }

Upvotes: 0

Related Questions