Skip to content

Commit

Permalink
Merge pull request react-bootstrap#853 from react-bootstrap/code-cove…
Browse files Browse the repository at this point in the history
…rage

Code coverage
  • Loading branch information
AlexKVal committed Jun 18, 2015
2 parents 2f0befc + 43ea569 commit ad8e39b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ docs-built/
tmp-bower-repo/
tmp-docs-repo/
.babel-cache/
.coverage/
28 changes: 25 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
/* eslint no-var: 0 */
/* eslint no-var: 0, object-shorthand: 0 */
require('babel/register');

var webpackConfig = require('./webpack/test.config.js');
var isCI = process.env.CONTINUOUS_INTEGRATION === 'true';
var runCoverage = process.env.COVERAGE === 'true' || isCI;
var devBrowser = process.env.PHANTOM ? 'PhantomJS' : 'Chrome';

var preprocessors = ['webpack', 'sourcemap'];
var reporters = ['mocha'];

if (runCoverage) {
webpackConfig = require('./webpack/test-coverage.config');
preprocessors.push('coverage');
reporters.push('coverage');

if (isCI) {
reporters.push('coveralls');
}
}

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

Expand All @@ -22,7 +36,7 @@ module.exports = function (config) {
],

preprocessors: {
'test/index.js': ['webpack', 'sourcemap']
'test/index.js': preprocessors
},

webpack: webpackConfig,
Expand All @@ -31,12 +45,20 @@ module.exports = function (config) {
noInfo: isCI
},

reporters: ['mocha'],
reporters: reporters,

mochaReporter: {
output: 'autowatch'
},

coverageReporter: {
dir: '.coverage',
reporters: [
{ type: 'html' },
{ type: 'lcovonly' }
]
},

port: 9876,

colors: true,
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"scripts": {
"build": "babel-node tools/build-cli.js",
"test-watch": "karma start",
"test-coverage": "npm run build && COVERAGE=true karma start --single-run",
"test": "npm run lint && npm run build && karma start --single-run && _mocha --compilers js:babel-core/register test/server/*Spec.js",
"lint": "eslint ./",
"docs-build": "babel-node tools/build-cli.js --docs-only",
Expand Down Expand Up @@ -63,11 +64,14 @@
"glob": "^5.0.10",
"http-proxy": "^1.11.1",
"ip": "^0.3.2",
"isparta-loader": "^0.2.0",
"json-loader": "^0.5.1",
"karma": "~0.12.32",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "~0.1.2",
"karma-cli": "0.0.4",
"karma-coverage": "^0.4.2",
"karma-coveralls": "^1.1.0",
"karma-firefox-launcher": "~0.1.3",
"karma-mocha": "~0.1.1",
"karma-mocha-reporter": "^1.0.2",
Expand Down
12 changes: 12 additions & 0 deletions webpack/test-coverage.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import _ from 'lodash';
import { jsLoader } from './base.config';
import testConfig from './test.config';

export default _.extend({}, testConfig, {
module: {
loaders: [
{ test: /\.js/, loader: `${jsLoader}!isparta`, exclude: /node_modules|test[\/\\]/ },
{ test: /\.js/, loader: jsLoader, include: /test[\/\\]/ }
]
}
});

0 comments on commit ad8e39b

Please sign in to comment.