【问题标题】:karma-remap-istanbul is generating the coverage htmls next to sourcekarma-remap-istanbul 正在源旁边生成覆盖 html
【发布时间】:2017-07-06 21:03:07
【问题描述】:

我正在尝试为我的 Aurelia (+ webpack + TypeScript) 网站设置单元测试。我的karma.conf.js 看起来如下(类似于 aurelia-navigation 骨架中所做的):

"use strict";
const path = require('path');

module.exports = function (config) {
  config.set({
    basePath: __dirname,
    frameworks: ['jasmine'],
    exclude: [],

    files: [{
      pattern: 'spec-bundle.js',
      watched: false
    } ],

    preprocessors: {
      'spec-bundle.js': ['coverage', 'webpack', 'sourcemap']
    },

    webpack: require('../webpack.config'),

    coverageReporter: {
      reporters: [
        {
          type: 'json',
          subdir: '.',
          file: 'coverage-final.json'
        },
        {
          type: 'html',
          dir: path.join(__dirname, 'coverage/'),
          subdir: '.'
        }
      ]
    },

    remapIstanbulReporter: {
      src: path.join(__dirname, 'coverage/coverage-final.json'),
      reports: {
        html: path.join(__dirname, 'coverage/remapped/')
      }
      // ,
      // timeoutNotCreated: 1000,
      // timeoutNoMoreFiles: 1000
    },

    webpackServer: { noInfo: true },

    reporters: ['mocha', 'coverage', 'karma-remap-istanbul'],    

    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: false,
    browsers: [
      // 'Chrome',
      'SlimerJS'
    ],
    singleRun: true
  });


  console.log(config);
};

我的文件夹结构如下:

Website
|-src
|-test
| |-coverage
| |-unit 
| | |-*.spec.ts
| |-karma.conf.js
| |-spec.bundle.js //as given by aurelia-navigation skeleton
|-webpack.config.js

问题在于karma-remap-istanbul 将覆盖html 转储到源旁边,而不是在test/coverage/remapped/ 中输出所有内容。

我是否缺少任何配置?

【问题讨论】:

    标签: javascript karma-runner aurelia istanbul karma-coverage


    【解决方案1】:

    尝试如下更新 remapIstanbulReporter 属性。

        remapIstanbulReporter: {
                src: path.join(__dirname, 'coverage/coverage-final.json'),
                reports: {
                    html: 'test/coverage/remapped'
                }
    
        }
    

    诀窍是在给出路径时,如果你放 './' 它需要相对路径 w.r.t 到文件夹结构中文件的位置。

    当您将路径指定为 'folder/folderA/folderB' 时,它采用绝对路径。

    【讨论】:

      猜你喜欢
      • 2016-05-23
      • 2016-02-29
      • 2016-06-02
      • 2015-09-10
      • 1970-01-01
      • 2015-12-19
      • 2014-04-26
      • 2017-11-11
      相关资源
      最近更新 更多