我创建了一个简单的Webpack + Typescript + Karma应用,但我无法让代码覆盖率正常工作。根据{{3}}等项目和this提供的其他信息,您可以看到我尝试了...
// In test bundle
const componentsContext = require.context('../src/', true, /\.js$/);
componentsContext.keys().forEach(componentsContext);
// In webpack config
const helpers = require('./helpers.js')
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
const commonConfig = require('./webpack.common.js'); // the settings that are common to prod and dev
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = function () {
return webpackMerge(commonConfig(), {
devtool: 'inline-source-map',
output: {
path: helpers.root("dist"),
filename: '[name].bundle.js',
},
module: {
postLoaders: [
{
test: /^((?!\.spec\.ts).)*.ts$/,
exclude: /(node_modules|bower_components)/,
loader: 'istanbul-instrumenter'
}
]
}
})
};
但是当我运行karma start test/karma.conf.js
时,我看到100%并且没有列出任何文件。我错过了什么?
答案 0 :(得分:0)
似乎修复了这个分支https://github.com/jrgleason/webpack-karma-coverage-demo/tree/fixed。虽然不确定是什么修复了它。