Skip to content

Instantly share code, notes, and snippets.

@AmitMY
Created September 7, 2017 05:06
Show Gist options
  • Save AmitMY/5d84223ce2262bd2ba3a99275a78e9b6 to your computer and use it in GitHub Desktop.
Save AmitMY/5d84223ce2262bd2ba3a99275a78e9b6 to your computer and use it in GitHub Desktop.
Karma no coverage
const path = require('path');
module.exports = function (config) {
config.set({
frameworks: ['jasmine'],
files: [
{pattern: 'src/**/*.spec.js', watched: true}
],
preprocessors: {
// add webpack as preprocessor
'src/**/*.spec.js': ['webpack', 'sourcemap']
},
webpack: {
devtool: 'inline-source-map',
resolve: {
extensions: ['.js']
},
module: {
rules: [
{
test: /\.js$/,
loaders: ['babel-loader'],
exclude: /node_modules/
}, {
test: /\.html$/,
loader: 'null-loader'
}, {
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'null-loader'
}
]
}
},
webpackMiddleware: {
stats: 'errors-only'
},
browserConsoleLogOptions: {
level: 'log',
format: '%b %T: %m',
terminal: true
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly', 'text-summary'],
// base output directory. If you include %browser% in the path it will be replaced with the karma browser name
dir: path.join(__dirname, 'coverage'),
// if using webpack and pre-loaders, work around webpack breaking the source path
fixWebpackSourcePaths: true,
},
reporters: config.coverage ? ['kjhtml', 'dots', 'coverage-istanbul'] : ['kjhtml', 'dots'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment