Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Test Coverage Check #1090

Merged
merged 33 commits into from
Mar 31, 2014
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e6af4c7
coverage
tarunc Mar 27, 2014
bb81279
updating coverage
tarunc Mar 27, 2014
a0dcc3d
karma
tarunc Mar 27, 2014
aac939a
fixint jshint
tarunc Mar 27, 2014
a8f6358
karma
tarunc Mar 27, 2014
d94f54e
karma coverage text reporter
tarunc Mar 27, 2014
065326a
lower coverage reqs to 50%
tarunc Mar 27, 2014
7b34364
dispute test
tarunc Mar 27, 2014
5f520f9
karma
tarunc Mar 27, 2014
4bb14cc
change transports
tarunc Mar 27, 2014
7c08b7e
fixing karma file
tarunc Mar 27, 2014
fd54181
downgrade karma
tarunc Mar 27, 2014
f8f76a8
npm shrinkwrap
tarunc Mar 27, 2014
b7c5ee2
reverting disputes
tarunc Mar 27, 2014
193120c
adding waitFor back to disputes
tarunc Mar 27, 2014
f247253
forget it
tarunc Mar 27, 2014
f4110e5
just forget it
tarunc Mar 27, 2014
eee2ed1
from html to lcov
tarunc Mar 27, 2014
da93851
finally working
tarunc Mar 27, 2014
e998859
updating package.json
tarunc Mar 27, 2014
5127315
modify threshold
tarunc Mar 27, 2014
d29f89d
added some istanbul ignores
tarunc Mar 27, 2014
bc537eb
add code climate
tarunc Mar 27, 2014
3854850
adding dispute tests
tarunc Mar 27, 2014
0d78fe5
dispute tests
tarunc Mar 27, 2014
61fbe69
fixing disputes tests
tarunc Mar 27, 2014
be36ced
fixing readme
tarunc Mar 27, 2014
c6d358f
jshint
tarunc Mar 27, 2014
249ab8d
coveralls repo token
tarunc Mar 27, 2014
e271298
add everyone in recent times to contributors file
tarunc Mar 27, 2014
08c6195
Merge remote-tracking branch 'upstream/master' into coverager
tarunc Mar 28, 2014
00fd874
fixing disputes
tarunc Mar 28, 2014
3f1db8c
waiting for helpers
tarunc Mar 31, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

es5 is now turned on by default in jshint. (it complains if we leave true in there)

"require": true,
Expand Down
43 changes: 40 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/']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we report check and report coverage, only keep most recent coverage report in there.

}
},

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,25 @@ 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: {
options: {
src: 'coverage/**/lcov.info'
}
}
});

Expand All @@ -651,6 +686,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 +703,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', 'karma', 'coverage', 'verify', 'coveralls']);

/*
Default task. Compiles templates, neuters application code, and begins
Expand Down Expand Up @@ -700,7 +737,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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[![Code Climate](https://codeclimate.com/github/balanced/balanced-dashboard.png)](https://codeclimate.com/github/balanced/balanced-dashboard)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


## 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 */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes code coverage skip lines (in this case an if statement)

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