Skip to content

Commit

Permalink
Adding code coverage reporting to Karma tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-roberts committed Oct 25, 2016
1 parent 8c90165 commit 770c8d0
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 5 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/**
**/vendor/**/*.js
**/coverage/**
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
node_modules/
coverage/
30 changes: 26 additions & 4 deletions h/static/scripts/karma.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var istanbul = require('browserify-istanbul');

module.exports = function(config) {
config.set({

Expand Down Expand Up @@ -57,10 +59,23 @@ module.exports = function(config) {
extensions: ['.coffee'],
noParse: [require.resolve('./vendor/katex')],
configure: function (bundle) {
bundle
.transform('coffeeify')
.plugin('proxyquire-universal');
bundle.plugin('proxyquire-universal');
},

transform: [
'coffeeify',
istanbul({
ignore: ['**/node_modules/**', '**/katex.js', '**/*.html', '**/*.svg'],

// There is an outstanding but with karma-converage and istanbul
// in regards to doing source mapping and transpiling CoffeeScript
// The least bad work around is to replace the instrumenter with
// isparta and it will handle doing the re mapping for us.
// This issue follows the issue and attempts to fix it:
// https://github.com/karma-runner/karma-coverage/issues/157
instrumenter: require('isparta'),
}),
],
},

mochaReporter: {
Expand All @@ -71,9 +86,16 @@ module.exports = function(config) {
output: 'minimal',
},

coverageReporter: {
type : 'html',

// place this in root of the project
dir : '../../../coverage/',
},

// Use https://www.npmjs.com/package/karma-mocha-reporter
// for more helpful rendering of test failures
reporters: ['mocha'],
reporters: ['mocha', 'coverage'],

// web server port
port: 9876,
Expand Down
65 changes: 64 additions & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"autoprefixer": "^6.0.3",
"babelify": "^6.1.3",
"browserify": "^13.0.0",
"browserify-istanbul": "^2.0.0",
"browserify-ngannotate": "^1.0.1",
"browserify-shim": "^3.8.12",
"browserify-versionify": "^1.0.6",
Expand Down Expand Up @@ -52,11 +53,14 @@
"gulp-util": "^3.0.7",
"hammerjs": "^2.0.4",
"inherits": "^2.0.1",
"isparta": "^4.0.0",
"istanbul": "^0.4.5",
"jquery": "1.11.1",
"js-polyfills": "^0.1.16",
"karma": "^1.1.0",
"karma-browserify": "^5.0.5",
"karma-chai": "^0.1.0",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.1.1",
"karma-mocha-reporter": "^2.0.4",
"karma-phantomjs-launcher": "^1.0.1",
Expand Down

0 comments on commit 770c8d0

Please sign in to comment.