【发布时间】:2017-11-11 06:05:13
【问题描述】:
我正在使用istanbul-instrumenter-loader 尝试为我的未转译的 es6 代码生成代码覆盖率报告,虽然一切运行良好,但生成的 HTML 输出中报告的问题似乎与实际来源不一致。
例如:
(以防图像被删除)
const 声明后面有 3 个“if 语句未覆盖”,即使该行之后根本没有这样的语句或任何代码。有时“语句未覆盖”标记在字符串中间,或在对象声明中,或跨多个语句等。
这是我的 Karma 配置文件:
module.exports = function(config) {
config.set({
basePath: '../../',
frameworks: [ 'qunit' ],
files: [
'test/index.js',
// Session tickets
{ pattern: 'test/tickets/*.json', watched: true, included: false, served: true }
],
preprocessors: {
'test/index.js': 'webpack'
},
webpack: {
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['istanbul-instrumenter-loader', 'babel-loader']
},
{
test: /\.vue$/,
loaders: ['vue-loader']
},
{
test: /\.png$/,
loaders: ['url-loader']
}]
}
},
reporters: [ 'coverage-istanbul', 'progress' ],
coverageIstanbulReporter: {
type: 'html',
dir: './coverage'
fixWebpackSourcePaths: true
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: [ 'Chrome' ],
browserNoActivityTimeout: 30000,
singleRun: true,
concurrency: Infinity,
client: {
captureConsole: true
},
browserConsoleLogOptions: {
terminal: true,
level: ''
}
})
};
【问题讨论】:
-
我面临着类似的情况,我的所有代码
else没有被覆盖,而else没有覆盖。你解决了吗? -
@HarryJoy 还是一无所有
-
能否为您的 js 文件和规范文件提供一个示例
-
我在 typescript3/webpack4/karma3 设置中遇到了同样的问题
标签: webpack ecmascript-6 karma-runner istanbul