简体   繁体   English

karma-remap-istanbul 正在生成源旁边的覆盖率 html

[英]karma-remap-istanbul is generating the coverage htmls next to source

I am trying to setup unit testing for my Aurelia (+ webpack + TypeScript) website.我正在尝试为我的 Aurelia (+ webpack + TypeScript) 网站设置单元测试。 My karma.conf.js looks as follows (similar to what is done in aurelia-navigation skeleton):我的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);
};

My folder structure is as follows:我的文件夹结构如下:

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

The problem is that karma-remap-istanbul is dumping the coverage htmls next to the source, instead of outputting everything in test/coverage/remapped/ .问题是karma-remap-istanbul正在将覆盖率 html 转储到源旁边,而不是在test/coverage/remapped/中输出所有内容。

Am I missing any configuration for this?我是否缺少任何配置?

Try Updating the remapIstanbulReporter attribute as follows.尝试更新remapIstanbulReporter属性,如下所示。

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

    }

The trick is while giving the path if you put './' It takes the relative path wrt to location of the file in folder structure.诀窍是在给出路径时,如果你把'./'放在文件夹结构中文件位置的相对路径。

Where as when you specify the path as 'folder/folderA/folderB' it takes the absolute path.当您将路径指定为'folder/folderA/folderB' 时,它采用绝对路径。

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

相关问题 使用 Karma/Istanbul 设置目标代码覆盖率 - Setting Target Code Coverage with Karma/Istanbul 向业报覆盖(伊斯坦布尔)代码覆盖率预处理器中添加角度控制器 - Add angular controllers to karma-coverage (Istanbul) code coverage preprocessor 咕噜模板茉莉花伊斯坦布尔没有生成报道报道 - grunt template jasmine istanbul is not generating coverage report Karma / Istanbul Code Coverage找不到功能并始终返回100% - Karma/Istanbul Code Coverage does not find functions and always returns 100% 使用Karma和Istanbul时从coverage中排除文件 - Excluding files from coverage when using Karma and Istanbul Istanbul代码覆盖率检查我的规范文件而不是源代码的覆盖率? - Istanbul code coverage checking coverage of my spec files instead of source? 错误:在 Angular2、Karma、Webpack 和伊斯坦布尔找不到源地图 - Error: Could not find source map for in Angular2, Karma, Webpack and Istanbul 业力-如何指向源地图进行打字稿覆盖 - Karma - How to point to a source map for typescript coverage Sourcemap + istanbul / isparta代码覆盖率为webpack + babel(对于es6)+ mocha(+ karma) - Sourcemap + istanbul/isparta code coverage for a webpack + babel (for es6) + mocha (+karma) 茉莉+伊斯坦布尔的覆盖范围无效 - Jasmine + Istanbul coverage not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM