Antoniossss
Antoniossss

Reputation: 32550

Cannot connect browser to Karma server (permanent page loading)

I am starting Karma using IntelliJ. Everything looks fine, new Chrome window pops up, but it keeps loading forever.

Karma log:

17 07 2018 13:29:01.754:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9877/
17 07 2018 13:29:01.758:INFO [launcher]: Launching browser Chrome with unlimited concurrency
17 07 2018 13:29:01.773:INFO [launcher]: Starting browser Chrome

 10% building modules 1/3 modules 2 active …ts\rafa-components-lib\src\polyfills.ts
 10% building modules 2/3 modules 1 active …ts\rafa-components-lib\src\polyfills.ts
 75% basic chunk optimization EnsureChunkConditionsPlugin
 75% basic chunk optimization RemoveParentModulesPlugin
 88% hashing
 90% additional chunk assets processing
 92% after chunk asset optimization SourceMapDevToolPlugin main.js generate SourceMap
Waiting for a captured browser... To capture a browser open http://localhost:9877/

Accessing localhost:9877 results in permanent loading. Sometimes it works as expected (karma starts and browser is connected) but it is kind of random.

Maybe someone have an idea what is going on??

Karma config:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage'),
      reports: ['html', 'lcovonly'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9877,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

New browser window: enter image description here

Connection is established: enter image description here

Upvotes: 4

Views: 2383

Answers (1)

Kim Kern
Kim Kern

Reputation: 60567

The same problem occurred to me in Webstorm.

I had a compilation problem in my tests, in my case it was ERROR in node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'..

In the Webstorm console the error was only shown after the browser had failed to be captured the third time. When you run ng test, you will instantly see the compilation error. After resolving it, the tests ran in Webstorm just fine.

Upvotes: 8

Related Questions