11'use strict' ;
2-
2+ var path = require ( 'path' ) ;
33
44module . exports = function ( config ) {
55 config . set ( {
@@ -13,13 +13,22 @@ module.exports = function(config) {
1313 ] ,
1414
1515 preprocessors : {
16- 'test/**/*.test.js' : [ 'webpack' , 'sourcemap' ]
16+ 'test/**/*.test.js' : [ 'webpack' , 'sourcemap' ] ,
17+
18+ 'lib/**/*.js' : [ 'coverage' ]
1719 } ,
1820
1921 webpack : {
2022 devtool : 'inline-source-map' ,
2123 module : {
22- postLoaders : [ ]
24+ rules : [
25+ {
26+ test : / \. j s $ / ,
27+ use : { loader : 'istanbul-instrumenter-loader' } ,
28+ include : path . resolve ( 'lib/' ) ,
29+ exclude : / ( ( t e s t | n o d e _ m o d u l e s ) \/ ) | ( l i b \/ d e t e c t \/ ( b r o w s e r .j s | e n v i r o n m e n t .j s ) ) /
30+ }
31+ ]
2332 }
2433 } ,
2534
@@ -29,6 +38,14 @@ module.exports = function(config) {
2938
3039 reporters : [ 'progress' ] ,
3140
41+ coverageReporter : {
42+ type : 'lcov' ,
43+ dir : 'coverage' ,
44+ instrumenterOptions : {
45+ istanbul : { noCompact : true }
46+ }
47+ } ,
48+
3249 frameworks : [ 'mocha' ] ,
3350
3451 customLaunchers : {
@@ -40,29 +57,15 @@ module.exports = function(config) {
4057
4158 // Number of browsers to run in parallel [set to 1 to avoid timing-based tests from failing]
4259 concurrency : 1 ,
43- // Using SafariNative launcher to due changes in Mojave: https://github.com/karma-runner/karma-safari-launcher/issues/29
44- browsers : [ 'Firefox' , 'Chrome' , 'SafariNative' ]
60+ browsers : [ 'Firefox' , 'Chrome' ]
4561
4662 } ) ;
4763
48- if ( process . argv . indexOf ( '--with-coverage' ) > - 1 ) {
49- config . webpack . module . postLoaders . push ( {
50- test : / \. j s $ / ,
51- exclude : / ( ( t e s t | n o d e _ m o d u l e s ) \/ ) | ( l i b \/ d e t e c t \/ ( b r o w s e r .j s | e n v i r o n m e n t .j s ) ) / ,
52- loader : 'istanbul-instrumenter'
53- } ) ;
54-
55- config . reporters . push ( 'coverage' ) ;
56-
57- config . coverageReporter = {
58- dir : 'coverage' ,
59- type : 'lcov'
60- } ;
61- }
62-
6364 if ( process . env . TRAVIS ) {
6465 config . browsers = [ 'Firefox' , 'Chrome_travis_ci' ] ;
6566 }
6667
67-
68+ if ( process . argv . indexOf ( '--with-coverage' ) > - 1 ) {
69+ config . reporters . push ( 'coverage' ) ;
70+ }
6871} ;
0 commit comments