Skip to content

Commit

Permalink
Merge pull request #1090 from tarunc/coverager
Browse files Browse the repository at this point in the history
Adding Test Coverage Check
  • Loading branch information
cohitre committed Mar 31, 2014
2 parents 0524a5c + 3f1db8c commit 13e7ce8
Show file tree
Hide file tree
Showing 16 changed files with 1,799 additions and 1,165 deletions.
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_name: travis-ci
repo_token: m3Z9p5t4SQLKw22IE9mkdr1iFSVpeJPoV
2 changes: 0 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"camelcase": true,
"indent": 4,
"white": false,
"curly": true,
Expand All @@ -15,7 +14,6 @@
"browser": true,
"jquery": true,
"camelcase": false,
"es5": true,
"globals": {
"module": true,
"require": true,
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ node_js:
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
env:
global:
- COVERALLS_REPO_TOKEN=m3Z9p5t4SQLKw22IE9mkdr1iFSVpeJPoV
10 changes: 9 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# individual or corporate CLA was used.
#
# Names should be added to this file like so:
# Name <email address> <github username> <twitter>
# Name <email address> <github username>
#
# Please keep the list sorted.
#
Expand All @@ -19,3 +19,11 @@ Nick Kleinschmidt <[email protected]> <kleinsch>
Ryan Loomba <[email protected]> <rloomba>
Kody Peterson <[email protected]> <headwebmonkey>
Chad Whitacre <[email protected]> <whit537>
Tarun Chaudhry <[email protected]> <tarunc>
Patrick Han <> <pkhan>
Carlos Rodriguez <[email protected]> <cohitre>
Kyungmin Kim <[email protected]> <kyungmin>
Dali Zheng <[email protected]> <daliwali>
Richie Serna <[email protected]> <rserna2010>
Patrick Cieplak <[email protected]> <cieplak>
Victor Lin <[email protected]> <victorlin>
44 changes: 41 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function(grunt) {
grunt.initConfig({
clean: {
files: {
src: ['build/', 'dist/', 'report/', 'js/', '.bower-tmp']
src: ['build/', 'dist/', 'report/', 'js/', '.bower-tmp', 'coverage/']
}
},

Expand All @@ -28,6 +28,13 @@ module.exports = function(grunt) {
src: ['app/dashboard.js'],
dest: 'build/js/includes-prod.js'
},
templates: {
options: {
template: "window.balancedSetupFunctions.push(function() { {%= src %} ; });"
},
src: ['build/js/compiled-templates.js'],
dest: 'build/js/test-templates.js'
},
testfixtures: {
options: {
template: "{%= src %} ;"
Expand All @@ -52,13 +59,22 @@ module.exports = function(grunt) {
dashboarddev: {
src: [
'app/app_setup.js',
'build/js/compiled-templates.js',
'build/js/includes-dev.js'
],
dest: 'build/js/dashboard-dev.js'
},
dashboardtest: {
src: [
'app/app_setup.js',
'build/js/includes-dev.js'
],
dest: 'build/js/dashboard-test.js'
},
dashboardprod: {
src: [
'app/app_setup.js',
'build/js/compiled-templates.js',
'build/js/includes-prod.js'
],
dest: 'build/js/dashboard-prod.js'
Expand Down Expand Up @@ -630,6 +646,26 @@ module.exports = function(grunt) {
dev: {
path: 'http://localhost:9876/build/dev.html'
},
},

coverage: {
options: {
thresholds: {
statements: 75,
branches: 61,
lines: 74,
functions: 76
},
dir: './coverage/',
root: '.'
}
},

coveralls: {
all: {
src: 'coverage/**/lcov.info',
force: true
}
}
});

Expand All @@ -651,6 +687,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-istanbul-coverage');
grunt.loadNpmTasks('grunt-coveralls');

grunt.registerMultiTask('clean', 'Deletes files', function() {
this.files.forEach(function(file) {
Expand All @@ -666,7 +704,7 @@ module.exports = function(grunt) {
A task to run the application's unit tests via the command line.
It will headlessy load the test runner page and print the test runner results
*/
grunt.registerTask('test', ['_devBuild', 'karma', 'jshint', 'verify']);
grunt.registerTask('test', ['_devBuild', 'verify', 'karma', 'coverage', 'coveralls:all']);

/*
Default task. Compiles templates, neuters application code, and begins
Expand Down Expand Up @@ -700,7 +738,7 @@ module.exports = function(grunt) {
grunt.registerTask('_prodBuildSteps', ['img', '_uglify', 'hashres', 'copy:dist']);

grunt.registerTask('_buildJS', ['emberTemplates', '_buildJSAfterTemplates']);
grunt.registerTask('_buildJSAfterTemplates', ['bower:install', 'neuter:dev', 'neuter:prod', 'concat:dashboarddev', 'concat:dashboardprod', 'concat:libdev', 'concat:libprod']);
grunt.registerTask('_buildJSAfterTemplates', ['bower:install', 'neuter:dev', 'neuter:prod', 'neuter:templates', 'concat:dashboarddev', 'concat:dashboardprod', 'concat:dashboardtest', 'concat:libdev', 'concat:libprod']);
grunt.registerTask('_buildTests', ['neuter:testfixtures', 'concat:libtest', 'concat:tests', 'copy:test']);
grunt.registerTask('_buildCSS', ['less']);
grunt.registerTask('_buildImages', ['copy:images']);
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
balanced-dashboard
==================

The Balanced Dashboard

[![Build Status](https://travis-ci.org/balanced/balanced-dashboard.png?branch=master)](https://travis-ci.org/balanced/balanced-dashboard)
[![Coverage Status](https://coveralls.io/repos/balanced/balanced-dashboard/badge.png)](https://coveralls.io/r/balanced/balanced-dashboard)
[![Code Climate](https://codeclimate.com/github/balanced/balanced-dashboard.png)](https://codeclimate.com/github/balanced/balanced-dashboard)

## What

Expand Down
4 changes: 2 additions & 2 deletions app/app_setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// This is pulled out into a separate file so the Grunt neuter task doesn't
// add templating code to it while building

window.balancedSetupFunctions = [];

/*
Expand Down Expand Up @@ -49,12 +48,12 @@ window.setupBalanced = function(divSelector) {
}
});

/* istanbul ignore if */
if (!window.TESTING) {
// Defer the readiness until we know about login session
window.Balanced.deferReadiness();
}


window.Balanced.onLoad = function() {
// initialize anything that needs to be done on application load
Balanced.Analytics.init(Ember.ENV.BALANCED);
Expand All @@ -68,6 +67,7 @@ window.setupBalanced = function(divSelector) {
setupFunction();
});

/* istanbul ignore if */
if (!window.TESTING) {
// Get the current login if logged in
window.Balanced.Auth.getCurrentLogin().always(function() {
Expand Down
9 changes: 0 additions & 9 deletions app/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/*
this file is generated as part of the build process.
If you haven't run that yet, you won't see it.
It is excluded from git commits since it's a
generated file.
*/
require('build/js/compiled-templates');

/*
* Helpers and utils - not static 3rd party libraries
*/
Expand Down
8 changes: 6 additions & 2 deletions app/lib/handlebars_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ Ember.Handlebars.registerBoundHelper('stringify', function(obj) {
Ember.Handlebars.registerBoundHelper('humanReadableDateShort', Balanced.Utils.humanReadableDateShort);
Ember.Handlebars.registerBoundHelper('humanReadableDateLong', Balanced.Utils.humanReadableDateLong);
Ember.Handlebars.registerBoundHelper('inflection', function(property, options) {
var length, singularForm, str;
var str;

if (options) {
length = property, singularForm = options.hash["singular"];
var length = property;
var singularForm = options.hash["singular"];

if ((parseInt(length, 10) > 1) || (parseInt(length, 10) === 0)) {
str = length + " " + singularForm + "s";
} else {
str = length + " " + singularForm;
}
}

return new Ember.Handlebars.SafeString(str);
});
38 changes: 34 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module.exports = function(config) {
'build/test/js/testenv.js',
'build/js/lib-dev.js',
'build/test/js/balanced.min.js',
'build/js/dashboard-dev.js',
'build/js/dashboard-test.js',
'build/js/test-templates.js',
'build/test/js/test-fixtures.js',
'build/test/js/testconfig.js',
'test/lib/*.js', {
Expand Down Expand Up @@ -61,16 +62,31 @@ module.exports = function(config) {
exclude: [],

preprocessors: {
'build/js/dashboard-dev.js': ['coverage']
'build/js/dashboard-test.js': ['coverage']
},

// An array of allowed transport methods between the browser and testing server.
// This configuration setting is handed off to socket.io
// Default values are ['websocket', 'flashsocket', 'xhr-polling', 'jsonp-polling']
// Does not work!
// transports: ['xhr-polling', 'jsonp-polling'],

// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress', 'coverage'],

coverageReporter: {
type: 'html',
dir: 'coverage/'
reporters: [{
type: 'lcov',
dir: 'coverage/'
}, {
type: 'json',
dir: 'coverage/'
}, {
type: 'text'
}, {
type: 'text-summary'
}]
},

// web server port
Expand Down Expand Up @@ -101,10 +117,24 @@ module.exports = function(config) {
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,

// How long does Karma wait for a browser to reconnect (in ms).
browserDisconnectTimeout: 180000,

// The number of disconnections tolerated
browserDisconnectTolerance: 100,

// How long does Karma wait for a message from a browser before disconnecting it (in ms).
browserNoActivityTimeout: 300000,

client: {
useIframe: false,
},

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true,

// Provide proxies
proxies: {
'/build': 'http://localhost:9877/build',
'/images': 'http://localhost:9877/build/images'
Expand Down
Loading

0 comments on commit 13e7ce8

Please sign in to comment.