繁体   English   中英

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

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

由于未知原因,我无法启动 angular 测试。 它无休止地说,“Chrome 在 60000 毫秒内没有捕获,正在杀死,ChromeHeadless 在 200 毫秒内没有被 SIGKILL 杀死,继续”。

我不知道是什么问题? 我身边缺少什么? 附件是这个的截图。

在此处输入图像描述

以下是 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 }
        ]
    };
};

您是否使用 puppeteer 安装 ChromeHeadless? 尝试指定可执行文件的路径,看看是否能让 ChromeHeadless 正常启动。

这是一个示例 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