diff --git a/Grunt/options/build.js b/Grunt/options/build.js index 522726931..668fa031a 100644 --- a/Grunt/options/build.js +++ b/Grunt/options/build.js @@ -5,6 +5,11 @@ module.exports = function(grunt){ build = grunt.config.get('environment.build'), travis = grunt.config.get('environment.travis'); + // Prepare karma preprocessor options for karma. + // ES5 does not support to write dynamic object attribtues directly. + var karmaPreProcessor = {}; + karmaPreProcessor[dir.build + '/mootools-core.js'] = ['coverage']; + var config = { clean: { 'build': {src: dir.build + '/mootools-*.js'} @@ -13,6 +18,14 @@ module.exports = function(grunt){ 'run': { options: { files: [dir.build + '/mootools-core.js', dir.build + '/mootools-specs.js'] + }, + reporters: ['coverage'], + preprocessors: karmaPreProcessor, + coverageReporter: { + dir: dir.build + '/reports/coverage', + reporters: [ + {type: 'html', subdir: 'report-html'} + ] } }, 'dev': { @@ -26,8 +39,23 @@ module.exports = function(grunt){ options: { files: [dir.build + '/mootools-core.js', dir.build + '/mootools-specs.js'] }, - reporters: ['progress', 'saucelabs'], - browsers: [travis.browser] + reporters: ['progress', 'saucelabs', 'coverage'], + browsers: [travis.browser], + preprocessors: karmaPreProcessor, + coverageReporter: { + dir: dir.build + '/reports/coverage', + reporters: [ + // TODO: pass this files to a coverage service e.g. "coveralls.io". + {type: 'lcov', subdir: 'report-lcov'}, + {type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt'} + ], + // Don't minify instrumenter output + instrumenterOptions: { + istanbul: { + noCompact: true + } + } + } } }, mochaTest: { diff --git a/package.json b/package.json index 1a743099e..2281b74be 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "grunt-karma": "^0.11.1", "grunt-mocha-test": "^0.12.7", "grunt-mootools-packager": "^0.4.0", - "karma": "^0.12.37", + "karma": "^1.1.1", + "karma-coverage": "^1.1.0", "karma-expect": "^1.1", "karma-mocha": "^0.2.0", "karma-phantomjs-launcher": "^0.2.1",