简体   繁体   English

ng 测试不起作用 业力无法启动“ChromeHeadless 在 2000 毫秒内没有被杀死,正在发送 SIGKILL。”

[英]ng test not working karma not able to start “ ChromeHeadless was not killed in 2000 ms, sending SIGKILL.”

I am not able to start angular tests due to unknown reasons.由于未知原因,我无法启动 angular 测试。 it says endlessly, "Chrome have not captured in 60000 ms, killing, ChromeHeadless was not killed by SIGKILL in 200ms, continuing".它无休止地说,“Chrome 在 60000 毫秒内没有捕获,正在杀死,ChromeHeadless 在 200 毫秒内没有被 SIGKILL 杀死,继续”。

I have no idea what is the problem?我不知道是什么问题? What is missing at my side?我身边缺少什么? Attached is the screenshot for this.附件是这个的截图。

在此处输入图像描述

Following is karma.conf.js以下是 karma.conf.js

  //Karma configuration file, see link for more information
 //https://karma-runner.github.io/1.0/config/configuration-file.html

const { join } = require('path');
  const getBaseKarmaConfig = require('../../karma.conf');

  module.exports = function(config) {
     const baseConfig = getBaseKarmaConfig();
     config.set({
    ...baseConfig,
    coverageIstanbulReporter: {
      ...baseConfig.coverageIstanbulReporter,
      dir: join(__dirname, '../../coverage/apps/login/')
    }
  });
};

and complete karma.conf.js is :

    // Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

const { join } = require('path');
const { constants } = require('karma');

module.exports = () => {
    return {
        basePath: process.cwd() + '/apps/login',
        frameworks: ['jasmine', '@angular-devkit/build-angular'],
        plugins: [
            require('karma-jasmine'),
            require('karma-chrome-launcher'),
            require('karma-junit-reporter'),
            require('karma-jasmine-html-reporter'),
            require('karma-coverage-istanbul-reporter'),
            require('karma-spec-reporter'),
            require('@angular-devkit/build-angular/plugins/karma')
        ],
        proxies : {
            '/assets/': 'assets/'
        },
        client: {
            clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
        coverageIstanbulReporter: {
            dir: join(__dirname, '../../coverage'),
            reports: ['html', 'lcovonly', 'text-summary'],
            fixWebpackSourcePaths: true,
            emitWarning: true,
            thresholds: {
                statements: 80,
                lines: 80,
                branches: 0,
                functions: 70
            }
        },
        reporters: ['spec', 'junit', 'kjhtml'],
        junitReporter: { outputFile: 'TEST-results.xml' },
        port: 9876,
        colors: true,
        logLevel: constants.LOG_INFO,
        autoWatch: false,
        browsers: ['ChromeHeadless'],
        singleRun: true,
        browserDisconnectTimeout: 10000,
        files: [
            { pattern: 'src/assets/img/*.png', watched: false, included:false, nocache:false, served:true },
            { pattern: 'src/assets/img/*.svg', watched: false, included:false, nocache:false, served:true },
            { pattern: 'src/assets/*.json', watched: false, included:false, nocache:false, served:true }
        ]
    };
};

Are you using puppeteer to install ChromeHeadless?您是否使用 puppeteer 安装 ChromeHeadless? Try specifying the path to the executable and see if that gets ChromeHeadless to launch properly.尝试指定可执行文件的路径,看看是否能让 ChromeHeadless 正常启动。

Here is a sample karma.conf.js:这是一个示例 karma.conf.js:

module.exports = function (config) {
  const puppeteer = require('puppeteer');
  process.env.CHROME_BIN = puppeteer.executablePath();

  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: {
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome', 'ChromeHeadless'],
    singleRun: true,
    restartOnFileChange: true
  });
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM