File tree Expand file tree Collapse file tree 5 files changed +23
-5
lines changed
Expand file tree Collapse file tree 5 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ node_modules
22* .log
33package-lock.json
44dist
5- build
5+ build
6+ coverage
Original file line number Diff line number Diff line change 3636 "dependencies" : {
3737 "babel-core" : " ^6.26.0" ,
3838 "babel-loader" : " ^7.1.2" ,
39+ "babel-plugin-istanbul" : " ^5.1.0" ,
3940 "babel-plugin-transform-object-rest-spread" : " ^6.26.0" ,
4041 "babel-plugin-transform-react-jsx" : " ^6.24.1" ,
4142 "babel-polyfill" : " ^6.26.0" ,
4647 "jasmine-core" : " ^2.9.1" ,
4748 "karma" : " ^2.0.0" ,
4849 "karma-chrome-launcher" : " ^2.2.0" ,
50+ "karma-coverage" : " ^1.1.2" ,
4951 "karma-jasmine" : " ^1.1.1" ,
5052 "karma-sourcemap-loader" : " ^0.3.7" ,
5153 "karma-spec-reporter" : " 0.0.32" ,
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ let prog = sade('karmatic');
1515prog
1616 . version ( version )
1717 . option ( '--files' , 'Minimatch pattern for test files' )
18- . option ( '--headless' , 'Run using Chrome Headless' , true ) ;
18+ . option ( '--headless' , 'Run using Chrome Headless' , true )
19+ . option ( '--coverage' , 'Report code coverage of tests' , true ) ;
1920
2021prog
2122 . command ( 'run [...files]' , '' , { default : true } )
Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ export default function configure(options) {
2727 'karma-spec-reporter' ,
2828 'karma-sourcemap-loader' ,
2929 'karma-webpack'
30- ] ;
30+ ] . concat (
31+ options . coverage ? 'karma-coverage' : [ ]
32+ ) ;
3133
3234 const WEBPACK_CONFIGS = [
3335 'webpack.config.babel.js' ,
@@ -109,7 +111,9 @@ export default function configure(options) {
109111 basePath : cwd ,
110112 plugins : PLUGINS . map ( require . resolve ) ,
111113 frameworks : [ 'jasmine' ] ,
112- reporters : [ 'spec' ] ,
114+ reporters : [ 'spec' ] . concat (
115+ options . coverage ? 'coverage' : [ ]
116+ ) ,
113117 browsers : [ options . headless === false ? 'KarmaticChrome' : 'KarmaticChromeHeadless' ] ,
114118
115119 customLaunchers : {
@@ -122,6 +126,14 @@ export default function configure(options) {
122126 }
123127 } ,
124128
129+ coverageReporter : {
130+ reporters : [
131+ { type : 'text-summary' } ,
132+ { type : 'html' } ,
133+ { type : 'lcovonly' , subdir : '.' , file : 'lcov.info' }
134+ ]
135+ } ,
136+
125137 formatError ( msg ) {
126138 try {
127139 msg = JSON . parse ( msg ) . message ;
Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ export default function babelLoader(options) {
1717 plugins : [
1818 [ require . resolve ( 'babel-plugin-transform-object-rest-spread' ) ] ,
1919 [ require . resolve ( 'babel-plugin-transform-react-jsx' ) , { pragma : options . pragma || 'h' } ]
20- ]
20+ ] . concat (
21+ options . coverage ? require . resolve ( 'babel-plugin-istanbul' ) : [ ]
22+ )
2123 }
2224 } ;
2325}
You can’t perform that action at this time.
0 commit comments