无法将浏览器连接到Karma服务器(永久页面加载)

时间:2018-07-17 11:32:28

标签: angular karma-runner

我正在使用IntelliJ启动Karma。一切看起来都很好,会弹出新的Chrome窗口,但它会永远加载。

业力日志:

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/

访问localhost:9877导致永久加载。有时它可以按预期运行(因果机制启动并且浏览器已连接),但这是随机的。

也许有人知道发生了什么事?

业力配置:

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
  });
};

新的浏览器窗口: enter image description here

建立连接: enter image description here

1 个答案:

答案 0 :(得分:6)

在Webstorm中,我也遇到了同样的问题。

我在测试中遇到了编译问题,在我的情况下是onPermissionRequestResult

在Webstorm控制台中,仅在第三次捕获浏览器失败后才显示该错误。运行ERROR in node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.时,会立即看到编译错误。解决之后,测试就可以在Webstorm中运行了。