Karma Jasmine Html报告没有出现在ng测试中

时间:2018-05-30 10:47:11

标签: angular unit-testing karma-jasmine

我在Chrome中运行单元测试时无法获得karma jasmine Html报告。 Chrome正在加载组件的HTML,但未显示测试结果。

然而,我在终端本身获得了测试结果。我已尝试在karma.config.js中添加以下内容,但会收到错误。

在Pulgins中 - >需要('卡玛 - 茉莉HTML的记者') 在记者 - > kjhtml

{

"message": "Uncaught TypeError: env.stopOnSpecFailure is not a function\nat node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:26:7\n\nTypeError: env.stopOnSpecFailure is not a function\n    at node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:26:7\n    at node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:76:3",

"str": "Uncaught TypeError: env.stopOnSpecFailure is not a function\nat node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:26:7\n\nTypeError: env.stopOnSpecFailure is not a function\n    at node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:26:7\n    at node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:76:3"

}

以下是package.json

中的版本
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "^4.1.0",
"karma": "~2.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^1.1.0",

以下是Karma.config.js

// Karma配置文件,有关详细信息,请参阅链接 // https://karma-runner.github.io/1.0/config/configuration-file.html

process.env.CHROME_BIN = require('puppeteer').executablePath();

module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-junit-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma'),
      require('karma-jasmine-html-reporter')
    ],
    client: {
      clearContext: false, // leave Jasmine Spec Runner output visible in browser
      captureConsole: false
    },
    junitReporter: {
      outputDir: 'reports/junit/',
      outputFile: 'TESTS-xunit.xml',
      useBrowserName: false,
      suite: '' // Will become the package name attribute in xml testsuite element
    },
    coverageIstanbulReporter: {
      reports: ['html', 'lcovonly', 'text-summary'],
      dir: './reports/coverage',
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'junit', 'kjhtml'],
    port: 9876,
    colors: true,
    // Level of logging, can be: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

0 个答案:

没有答案