Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Fix test coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
jhellar committed Aug 15, 2017
1 parent d972b00 commit 0598698
Show file tree
Hide file tree
Showing 5 changed files with 6,084 additions and 9,663 deletions.
35 changes: 25 additions & 10 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,26 @@ module.exports = function(grunt) {
}
},
shell: {
jscov: {
//NOTE: install node-jscoverage first from here: https://github.com/visionmedia/node-jscoverage
command: 'jscoverage src/ src-cov/ --exclude=appforms',
options: {
stdout: true
}
},
htmlcov: {
//NOTE: install jsoncov2htmlcov first from here: https://github.com/plasticine/json2htmlcov
command: 'json2htmlcov rep/coverage.json > rep/coverage.html',
command: 'cat rep/coverage.json | ./node_modules/.bin/json2htmlcov > rep/coverage.html',
options: {
stdout: true
}
}
},
jscoverage: {
src: {
expand: true,
cwd: 'src/',
src: ['*.js', 'modules/**/*.js'],
dest: 'src-cov/',
ext: '.js',
}
},
coveralls: {
target: {
src: 'rep/coverage.lcov'
}
}
});

Expand All @@ -322,6 +328,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks("grunt-jscoverage");
grunt.loadNpmTasks('grunt-coveralls');

var spawns = [];
grunt.registerTask('start-local-servers', function () {
Expand Down Expand Up @@ -367,6 +375,13 @@ module.exports = function(grunt) {

});

grunt.registerTask('json2lcov', function() {
var jsoncovToLcov = require('json2lcov');
var jsonCovResult = grunt.file.readJSON('rep/coverage.json');
var lcov = jsoncovToLcov(jsonCovResult);
grunt.file.write('rep/coverage.lcov', lcov);
});

var stopLocalServers = function(){
spawns.forEach(function (server) {
grunt.log.writeln("Killing process " + server.pid);
Expand Down Expand Up @@ -402,7 +417,7 @@ module.exports = function(grunt) {

grunt.registerTask('titanium', 'concat-titanium browserify:dist_titanium concat-titanium-globals');

grunt.registerTask('coverage', ['shell:jscov', 'browserify:require_cov', 'browserify:test_cov', 'connect:server', 'mocha_phantomjs:test_coverage', 'shell:htmlcov']);
grunt.registerTask('coverage', ['jscoverage', 'browserify:require_cov', 'browserify:test_cov', 'connect:server', 'mocha_phantomjs:test_coverage', 'shell:htmlcov', 'json2lcov']);

grunt.registerTask('default', 'jshint concat-core-sdk concat:forms_appFormsTest test titanium uglify:dist zip');
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,16 @@
"grunt-contrib-qunit": "~0.4.0",
"grunt-contrib-uglify": "0.3.2",
"grunt-contrib-watch": "0.6.0",
"grunt-coveralls": "^1.0.1",
"grunt-env": "0.4.1",
"grunt-jscoverage": "^0.1.3",
"grunt-mocha-phantomjs": "0.4.3",
"grunt-mocha-test": "0.9.4",
"grunt-shell": "0.6.4",
"grunt-text-replace": "0.3.12",
"grunt-zip": "0.12.0",
"json2htmlcov": "^0.1.1",
"json2lcov": "^1.0.0",
"mocha": "1.17.1",
"moment": "^2.18.1",
"rimraf": "2.6.1",
Expand Down
2 changes: 1 addition & 1 deletion rep/coverage.html

Large diffs are not rendered by default.

Loading

0 comments on commit 0598698

Please sign in to comment.