11/* eslint-env node */
22/* eslint no-process-env: 0 */
3+ const path = require ( 'path' )
4+ const jsCoveragePath = path . resolve ( __dirname , '../coverage' )
35
46module . exports = ( config ) => {
57 const jqueryFile = process . env . USE_OLD_JQUERY ? 'js/tests/vendor/jquery-1.9.1.min.js' : 'assets/js/vendor/jquery-slim.min.js'
@@ -11,18 +13,19 @@ module.exports = (config) => {
1113 'karma-chrome-launcher' ,
1214 'karma-firefox-launcher' ,
1315 'karma-qunit' ,
14- 'karma-detect-browsers'
16+ 'karma-detect-browsers' ,
17+ 'karma-coverage-istanbul-reporter'
1518 ] ,
1619 // list of files / patterns to load in the browser
1720 files : [
1821 jqueryFile ,
1922 'assets/js/vendor/popper.min.js' ,
20- 'js/dist/util.js' ,
21- 'js/dist/tooltip.js' ,
22- 'js/dist/!(util|index|tooltip).js' , // include all of our js/dist files except util.js, index.js and tooltip.js
23+ 'js/coverage/ dist/util.js' ,
24+ 'js/coverage/ dist/tooltip.js' ,
25+ 'js/coverage/ dist/!(util|index|tooltip).js' , // include all of our js/dist files except util.js, index.js and tooltip.js
2326 'js/tests/unit/*.js'
2427 ] ,
25- reporters : [ 'dots' ] ,
28+ reporters : [ 'dots' , 'coverage-istanbul' ] ,
2629 port : 9876 ,
2730 colors : true ,
2831 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
@@ -49,6 +52,20 @@ module.exports = (config) => {
4952
5053 throw new Error ( 'Please install Firefox or Chrome' )
5154 }
55+ } ,
56+ coverageIstanbulReporter : {
57+ dir : jsCoveragePath ,
58+ reports : [ 'lcov' , 'text-summary' ] ,
59+ fixWebpackSourcePaths : true ,
60+ thresholds : {
61+ emitWarning : true ,
62+ global : {
63+ statements : 80 ,
64+ lines : 80 ,
65+ branches : 80 ,
66+ functions : 80
67+ }
68+ }
5269 }
5370 } )
5471}
0 commit comments