首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >karma -htmlfile-karma上的记者开始不提供html输出

karma -htmlfile-karma上的记者开始不提供html输出
EN

Stack Overflow用户
提问于 2017-09-21 18:01:15
回答 1查看 2.6K关注 0票数 1

我正在使用karma angular-cli通过jasminejavascript运行测试用例。

在我的karma.config文件中,我添加了以下几行。

代码语言:javascript
复制
reporters: ['progress','html'],


htmlReporter: {
   outputFile: 'test/units.html'
},

我在命令提示符下运行这个命令

代码语言:javascript
复制
karma start --reporters html

但是我得到的不是测试用例的结果,而是这些。

编辑:添加karma.conf.js

代码语言:javascript
复制
// Karma configuration
// Generated on Tue Sep 26 2017 18:46:51 GMT+0530 (India Standard Time)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      'test-main.js',
      'js/*.js', 
       'test/*.js'
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter

    client: {
        clearContext: false
    },
    reporters: ['kjhtml','html'],

    plugins: ['karma-chrome-launcher',
        'karma-firefox-launcher',
        'karma-jasmine',
        'karma-jasmine-html-reporter'],

    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}

添加了package.json

代码语言:javascript
复制
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "karma.conf.js",
  "directories": {
    "test": "test"
  },
  "dependencies": {
    "jasmine": "^2.7.0",
    "karma": "^1.7.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-firefox-launcher": "^1.0.1",
    "karma-ie-launcher": "^1.0.0",
    "karma-jasmine": "^1.1.0",
    "karma-requirejs": "^1.1.0"
  },
  "devDependencies": {
    "jasmine": "^2.8.0",
    "jasmine-core": "^2.8.0",
    "karma": "^1.7.1",
    "karma-chrome-launcher": "^2.2.0",
    "karma-htmlfile-reporter": "~0.3",
    "karma-jasmine": "^1.1.0",
    "karma-jasmine-html-reporter": "^0.1.8",
    "karma-requirejs": "^1.1.0",
    "karma-spec-reporter": "0.0.31"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

我得到的结果是

有没有人能帮我在html中生成测试用例结果?

EN

回答 1

Stack Overflow用户

发布于 2017-09-26 20:54:32

使用karma - jasmine -html-report在karma横幅下打印jasmine格式的报告。

karma-jasmine-html-记者:https://github.com/taras42/karma-jasmine-html-reporter

在karma.conf.js文件中添加以下内容

代码语言:javascript
复制
module.exports = function(config) {
  config.set({
    client: {
        clearContext: false
    },
    reporters: ['kjhtml'],

    plugins: ['karma-jasmine-html-reporter'] 

  });
};

以上述方式配置karma将产生以下结果:

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46340997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档