Skip to content

Commit

Permalink
Merge pull request #903 from OpenGeoscience/babel-coverage-reporting
Browse files Browse the repository at this point in the history
Fix reporting coverage when using babel.
  • Loading branch information
manthey authored Aug 28, 2018
2 parents 0fee4a3 + 1a748f7 commit a0f418b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion karma-base.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var webpack_config = require('./webpack.config');
var webpack_config = require('./webpack.base.config');
var url = require('url');
var fs = require('fs');
var path = require('path');
Expand Down
12 changes: 5 additions & 7 deletions karma-cov.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Defines a test server for running jasmine unit tests
// with coverage support.

var path = require('path');

/**
* Return URL friendly browser string
*/
Expand Down Expand Up @@ -40,11 +38,11 @@ module.exports = function (config) {
{type: 'text'}
]
};
karma_config.webpack.module.rules.unshift({
test: /\.js$/,
include: path.resolve('src/'),
exclude: path.resolve('src/polyfills.js'),
use: ['istanbul-instrumenter-loader']
/* Alter our first webpack module rule which should just apply to src/*.js
* files. */
karma_config.webpack.module.rules[0].use.push({
loader: 'istanbul-instrumenter-loader',
options: {esModules: true}
});

config.set(karma_config);
Expand Down
28 changes: 24 additions & 4 deletions webpack.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,32 @@ module.exports = {
*/
module: {
rules: [{
/* The first rule only includes src/*.js so that it can conveniently be
* modified for istanbul instrumentation */
test: /\.js$/,
include: path.resolve('src'),
exclude: path.resolve('src/polyfills.js'),
use: [{
loader: 'babel-loader',
options: {
presets: [[
'env', {
targets: {
browsers: ['defaults'],
uglify: true
},
useBuiltIns: 'usage'
}
]],
cacheDirectory: true
}
}]
}, {
test: /\.js$/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'tests'),
path.resolve(__dirname, 'examples'),
path.resolve(__dirname, 'tutorials')
path.resolve('tests'),
path.resolve('examples'),
path.resolve('tutorials')
],
use: [{
loader: 'babel-loader',
Expand Down

0 comments on commit a0f418b

Please sign in to comment.