Skip to content

Instantly share code, notes, and snippets.

@43081j
Created August 23, 2017 14:16
Show Gist options
  • Save 43081j/aaafee673e26cebf5a40b29979583e60 to your computer and use it in GitHub Desktop.
Save 43081j/aaafee673e26cebf5a40b29979583e60 to your computer and use it in GitHub Desktop.
Polymer + Webpack + Karma config
const webpackConfig = require('./webpack.config.js');
const webpack = require('webpack');
const path = require('path');
delete webpackConfig.entry;
webpackConfig.bail = false;
webpackConfig.stats = 'errors-only';
webpackConfig.plugins.push(new webpack.SourceMapDevToolPlugin({
filename: null,
test: /\.(ts|js)($|\?)/i
}));
webpackConfig.module.rules.push({
enforce: 'post',
test: /\.ts$/,
include: path.resolve(__dirname, 'src'),
exclude: path.resolve(__dirname, 'src/test'),
loader: 'istanbul-instrumenter-loader',
options: {
esModules: true
}
});
module.exports = function(config) {
config.set({
basePath: '',
browsers: ['ChromeHeadless'],
frameworks: ['mocha'],
reporters: ['progress', 'coverage-istanbul'],
files: [
{ pattern: 'bower_components/webcomponentsjs/webcomponents-lite.js', included: true, watched: false },
{ pattern: 'src/test/index.ts', included: true, watched: false },
{ pattern: 'bower_components/**/*', included: false, watched: false }
],
mime: {
'text/x-typescript': ['ts']
},
preprocessors: {
'src/test/index.ts': ['webpack', 'sourcemap']
},
webpack: webpackConfig,
coverageIstanbulReporter: {
dir: 'coverage/',
reports: ['html'],
fixWebpackSourcePaths: true
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment