【发布时间】:2017-12-19 11:23:30
【问题描述】:
我正在尝试使用 karma 来测试我的文件 array.js,这个文件只有 36 行,但是,覆盖率报告显示“Lines ....”(见我上传的 png),这是什么意思值,为什么它与我的测试代码不匹配?是我使用es6的原因吗? 我怎样才能得到正确的报告?
业力配置,
const webpackConfig = {
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|vendor)/,
loader: 'babel-loader'
}
]
}
};
module.exports = function (config) {
config.set({
basePath: '../',
plugins: [
'karma-webpack',
'karma-mocha',
'karma-phantomjs-launcher',
'karma-verbose-reporter',
'karma-coverage'
],
webpack: webpackConfig,
webpackServer: {
noInfo: true
},
frameworks: ['mocha'],
files: [
'test/**/*.js',
'src/**/*.js'
],
preprocessors: {
'test/**/*.js': ['webpack'],
'src/**/*.js': ['webpack', 'coverage']
},
reporters: ['verbose', 'coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
concurrency: Infinity,
coverageReporter: {
includeAllSources: true,
dir: 'coverage/',
reporters: [
{type: "html", subdir: "html"},
{type: 'text-summary'}
]
}
});
};
【问题讨论】:
标签: javascript unit-testing karma-runner