Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma: cannot start chrome #1662

Closed
nandha111 opened this issue Oct 27, 2015 · 11 comments · Fixed by #2522 or karronoli/redpen#10 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132
Closed

Karma: cannot start chrome #1662

nandha111 opened this issue Oct 27, 2015 · 11 comments · Fixed by #2522 or karronoli/redpen#10 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132

Comments

@nandha111
Copy link

For my angularjs project, trying to use karma+jamine for unit testing. I have installed karma @ local and trying to start from .bin folder. So i'm getting following issue; FYI I'm pasting folder structure along with,

ERROR,
C:\Workspace\node_modules\.bin>karma start ../../karma.conf.js
27 10 2015 09:57:06.461:WARN [karma]: No captured browser, open http://localhost:9876/
27 10 2015 09:57:06.486:INFO [karma]: Karma v0.13.11 server started at http://localhost:9876/
27 10 2015 09:57:06.500:INFO [launcher]: Starting browser Chrome
27 10 2015 09:57:07.111:ERROR [launcher]: Cannot start Chrome
27 10 2015 09:57:07.119:INFO [launcher]: Trying to start Chrome again (1/2).
27 10 2015 09:57:07.491:ERROR [launcher]: Cannot start Chrome
27 10 2015 09:57:07.493:INFO [launcher]: Trying to start Chrome again (2/2).
27 10 2015 09:57:08.234:ERROR [launcher]: Cannot start Chrome
27 10 2015 09:57:08.236:ERROR [launcher]: Chrome failed 2 times (cannot start).Giving up.
27 10 2015 09:57:08.633:INFO [Chrome 46.0.2490 (Windows 7 0.0.0)]: Connected on
socket PgWwwQDh6BZ7k9fpAAAA with id 74171654
27 10 2015 09:57:18.954:WARN [Chrome 46.0.2490 (Windows 7 0.0.0)]: Disconnected
(1 times), because no message in 10000 ms.
27 10 2015 09:57:18.957:ERROR [karma]: [TypeError: Cannot read property 'map' of
 undefined]TypeError: Cannot read property 'map' of undefined   at _render (C:\Workspace\node_modules\karma\lib\reporters\progress.js:51:26)
    at _refresh (C:\Workspace\node_modules\karma\lib\reporters\progress.js:55:34)
    at onBrowserComplete (C:\Workspace\node_modules\karma\lib\reporters\prog
ress.js:15:21)
    at null.<anonymous> (C:\Workspace\node_modules\karma\lib\events.js:13:22
)
    at emitOne (events.js:82:20)
    at emit (events.js:169:7)
    at null._onTimeout (C:\Workspace\node_modules\karma\lib\browser.js:50:15
)
    at Timer.listOnTimeout (timers.js:89:15)
Folder Structure,
node_modules
src
test
karma.conf
package.json

karma.conf
module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    plugins: [
        'karma-phantomjs-launcher',
        'karma-jasmine',
        'karma-coverage',
        'karma-chrome-launcher' ,
        'karma-firefox-launcher',
        'karma-requirejs',
        'karma-ie-launcher' 
    ],
    files: [
    'src/assets/js/angular.js',
        'src/assets/js/angular-mocks.js',
        'src/app/**/*.js',
        'test/*.js'
     ],
    preprocessors: {
        'src/app/**/*.js': ['coverage']
    },
    reporters: ['progress','coverage'],
    coverageReporter: {
        type: 'html',
        dir: 'coverage'
    },
    logLevel: config.LOG_INFO,
    browsers: ['Chrome'],
    singleRun: false
  });
};

@dignifiedquire
Copy link
Member

Can you try without coverage activated?

@nandha111
Copy link
Author

Yes I tried by removing them in karma.conf.js (as below) and started karma but still I'm getting same issue.I hope uninstall coverage doesn't make sense.
preprocessors: { },
reporters: ['progress'],
/* coverageReporter: {type: 'html',dir: 'coverage'}, */

@zombiecodekill
Copy link

I am getting the same error with Karma v0.13.22 and Chrome 50:

07 06 2016 12:03:25.680:INFO [Chrome 50.0.2661 (Windows 7 0.0.0)]: Connected on
socket /#ZNwS_jYb-Zjz-BTPAAAE with id 33459280
07 06 2016 12:03:27.823:WARN [IE 11.0.0 (Windows 7 0.0.0)]: Disconnected (1 time
s), because no message in 10000 ms.
07 06 2016 12:03:27.825:ERROR [karma]: TypeError: Cannot read property 'map' of
undefined
at _render (C:\workspace\node_modules\karma\lib\repo
rters\progress.js:51:26)
at _refresh (C:\workspace\node_modules\karma\lib\rep
orters\progress.js:55:34)
at onBrowserComplete (C:\workspace\node_modules\karm
a\lib\reporters\progress.js:15:21)
at . (C:\workspace\node_modules\karma\lib
\events.js:13:22)
at emitOne (events.js:101:20)
at emit (events.js:188:7)
at Timeout._onTimeout (C:\workspace\node_modules\kar
ma\lib\browser.js:50:15)
at tryOnTimeout (timers.js:224:11)
at Timer.listOnTimeout (timers.js:198:5)
TypeError: Cannot read property 'map' of undefined
at _render (C:\workspace\node_modules\karma\lib\repo
rters\progress.js:51:26)
at _refresh (C:\workspace\node_modules\karma\lib\rep
orters\progress.js:55:34)
at onBrowserComplete (C:\workspace\node_modules\karm
a\lib\reporters\progress.js:15:21)
at . (C:\workspace\node_modules\karma\lib
\events.js:13:22)
at emitOne (events.js:101:20)
at emit (events.js:188:7)
at Timeout._onTimeout (C:\workspace\node_modules\kar
ma\lib\browser.js:50:15)
at tryOnTimeout (timers.js:224:11)

If I remove Chrome from the list of browsers in karma.conf.js, then the tests run successfully in Firefox.

@dignifiedquire
Copy link
Member

Looks like in https://github.com/karma-runner/karma/blob/v0.13.22/lib/reporters/progress.js#L51 this._browsers is undefined instead of [] when no browsers have been spawned sometimes.

@trodrigues
Copy link

Just came across this bug as well. Weirdly enough, this started happening once I turned autoWatch to false.

Here's my config:

var _ = require('lodash');
var webpackCommonConfig = require('./webpack.common.js');

module.exports = function(config) {
  config.set({
    basePath: 'tests',
    frameworks: ['jasmine'],
    files: [
      '../src/utils/intl_polyfill.js',
      '*.spec.js'
    ],
    exclude: [],
    preprocessors: {
      '../src/*.js': ['webpack'],
      '../src/**/*.js': ['webpack'],
      '../locales/*.js': ['webpack'],
      '*.spec.js': ['webpack'],
      '*Data.js': ['webpack']
    },
    webpack: _.merge({
      devtool: 'inline-source-map'
    }, webpackCommonConfig),
    webpackMiddleware: {
      stats: 'errors-only'
    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_ERROR,
    autoWatch: false,
    browsers: ['PhantomJS'],
    singleRun: false,
    concurrency: Infinity
  })
}

@castamir
Copy link

ping
any progress with autoWatch: false?

@trodrigues
Copy link

It seems like this issue is fixed for me now, when using autoWatch. I have the following versions of the relevant packages:

node_modules/karma-chrome-launcher/package.json
  "version": "2.0.0"
node_modules/karma-webpack/package.json
  "version": "1.8.0"
node_modules/karma/package.json
  "version": "1.3.0"

karma and karma-webpack had updates since the version I set on my package.json so I assume one of them fixed the issue.

@maksimr
Copy link
Contributor

maksimr commented Jan 1, 2017

I have simple use case which reproduce this problem on macOs:

mkdir foo
cd foo
node --version #v7.3.0
npm install karma@1.3.0
npm install -g karma-cli
karma init # Chrome, jasmine
npm install jasmine-core


# karma-chrome-launcher@2.0.0
# karma-jasmine@1.1.0

karma start

# In opened Chrome reload page (cmd+r) 

karma.conf.js

Note:

If onRunStart does not called then this._browser is not initialized, but when you reload page in chrome render or remove methods are called so they throw exception because this._browsers is undefined

@wvicioso
Copy link

Was this ever resolved? Same issue. Why was this closed?

@Dok11
Copy link

Dok11 commented Dec 10, 2017

I did not found decision too :(

@maksimr
Copy link
Contributor

maksimr commented Dec 10, 2017

@wvicioso @Dok11 we fixed javascript exception in karma

"TypeError: Cannot read property 'map' of
undefined]TypeError: Cannot read property 'map' of undefined"

It doesn't fix the reason why Chrome doesn't start because in 90% it's environment problem or problem in karma-chrome-launcher.
Did you run karma with log level equals debug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment