I have created a simple Webpack + Typescript + Karma app but I am having trouble getting the code coverage to work properly. Per projects like this and the other info provided here you can see I tried...
// 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'
}
]
}
})
};
but when I run karma start test/karma.conf.js
I see 100% and no files listed. What am I missing?
Seems fixed on this branch https://github.com/jrgleason/webpack-karma-coverage-demo/tree/fixed . Not exactly sure what fixed it though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.