[英]karma-remap-istanbul is generating the coverage htmls next to source
我正在尝试为我的 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/
中输出所有内容。
我是否缺少任何配置?
尝试更新remapIstanbulReporter属性,如下所示。
remapIstanbulReporter: {
src: path.join(__dirname, 'coverage/coverage-final.json'),
reports: {
html: 'test/coverage/remapped'
}
}
诀窍是在给出路径时,如果你把'./'放在文件夹结构中文件位置的相对路径。
当您将路径指定为'folder/folderA/folderB' 时,它采用绝对路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.