diff --git a/.gitignore b/.gitignore index c83e4d526b..145ae5edc2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,12 @@ tmp/ ext/ node_modules/ +coverage/ +test/ .grunt/ npm-debug.log _SpecRunner.html bower_components/ .idea .grunt -reports \ No newline at end of file +reports diff --git a/.npmignore b/.npmignore index d12eeaac89..226c862b50 100644 --- a/.npmignore +++ b/.npmignore @@ -8,3 +8,5 @@ component.json bower_components tmp SpecRunner.html +coverage +test diff --git a/.travis.yml b/.travis.yml index 8daa629966..380fdd7b95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,3 +5,5 @@ before_install: - npm config set ca "" before_script: - npm run-script bower +after_success: + - npm run-script coverage diff --git a/Gruntfile.js b/Gruntfile.js index f886198ee0..ebe9a63dfc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -119,6 +119,20 @@ module.exports = function(grunt) { } }, + env: { + coverage: { + APP_DIR_FOR_CODE_COVERAGE: '../../../test/tmp/' + } + }, + + instrument: { + files: 'tmp/backbone.marionette.js', + options: { + lazy: true, + basePath: 'test' + } + }, + mochaTest: { tests: { options: { @@ -134,6 +148,30 @@ module.exports = function(grunt) { } }, + storeCoverage: { + options: { + dir: 'coverage' + } + }, + makeReport: { + src: 'coverage/**/*.json', + options: { + type: 'lcov', + dir: 'coverage', + print: 'detail' + } + }, + + coveralls: { + options: { + src: 'coverage/lcov.info', + force: false + }, + default: { + src: 'coverage/lcov.info' + } + }, + plato: { marionette : { src : 'src/*.js', @@ -254,6 +292,8 @@ module.exports = function(grunt) { grunt.registerTask('test', 'Run the unit tests.', ['verify-bower', 'lint', 'unwrap', 'preprocess:bundle', 'template:bundle', 'mochaTest']); + grunt.registerTask('coverage', ['unwrap', 'preprocess:bundle', 'template:bundle', 'env:coverage', 'instrument', 'mochaTest', 'storeCoverage', 'makeReport', 'coveralls']); + grunt.registerTask('dev', 'Auto-lints while writing code.', ['test', 'watch:marionette']); grunt.registerTask('build', 'Build all three versions of the library.', ['clean:lib', 'bower:install', 'lint', 'unwrap', 'preprocess', 'template', 'mochaTest', 'concat', 'uglify']); diff --git a/package.json b/package.json index d590588788..8f640b66af 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ ], "scripts": { "bower": "bower install", - "test": "grunt test --mocha-reporter=dot" + "test": "grunt test --mocha-reporter=dot", + "coverage": "grunt coverage --mocha-reporter=dot" }, "author": { "name": "Derick Bailey", @@ -46,30 +47,33 @@ "underscore": "1.4.4 - 1.6.0" }, "devDependencies": { + "bower": "1.2.8", + "chai": "^1.9.1", + "chai-jq": "0.0.7", + "chai-jquery": "^1.2.1", "grunt": "~0.4.5", + "grunt-bower-task": "~0.3.4", + "grunt-cli": "0.1.13", + "grunt-contrib-clean": "~0.5.0", + "grunt-contrib-concat": "~0.1.2", + "grunt-contrib-connect": "^0.1.2", "grunt-contrib-jshint": "^0.10.0", - "grunt-plato": "~0.1.4", "grunt-contrib-uglify": "~0.2.0", - "grunt-contrib-concat": "~0.1.2", "grunt-contrib-watch": "^0.6.1", - "grunt-contrib-connect": "^0.1.2", - "load-grunt-tasks": "0.3.0", + "grunt-coveralls": "^0.3.0", + "grunt-env": "^0.4.1", + "grunt-istanbul": "^0.3.0", "grunt-lintspaces": "^0.4.1", - "bower": "1.2.8", - "grunt-cli": "0.1.13", - "grunt-contrib-clean": "~0.5.0", + "grunt-mocha-test": "^0.10.2", + "grunt-plato": "~0.1.4", "grunt-preprocess": "~4.0.0", - "unwrap": "^0.1.0", - "grunt-bower-task": "~0.3.4", "grunt-template": "^0.2.3", - "sinon-chai": "^2.5.0", - "chai": "^1.9.1", + "jquery": "^2.1.1", + "jsdom": "^0.10.5", + "load-grunt-tasks": "0.3.0", "mocha": "^1.19.0", - "grunt-mocha-test": "^0.10.2", "sinon": "^1.9.1", - "jsdom": "^0.10.5", - "jquery": "^2.1.1", - "chai-jquery": "^1.2.1", - "chai-jq": "0.0.7" + "sinon-chai": "^2.5.0", + "unwrap": "^0.1.0" } } diff --git a/readme.md b/readme.md index d7b6c68a22..d891a74c6d 100644 --- a/readme.md +++ b/readme.md @@ -7,6 +7,9 @@ + + Coverage Status +

## About Marionette diff --git a/spec/javascripts/setup/node.js b/spec/javascripts/setup/node.js index ebcb09b7d7..3c199eb06e 100644 --- a/spec/javascripts/setup/node.js +++ b/spec/javascripts/setup/node.js @@ -2,6 +2,7 @@ var chai = require('chai'); var sinon = require('sinon'); var sinonChai = require('sinon-chai'); var chaiJq = require('chai-jq'); +var requireHelper = require('./require_helper'); chai.use(sinonChai); chai.use(chaiJq); @@ -31,4 +32,4 @@ global.$ = global.jQuery = require('jquery'); global._ = require('underscore'); global.Backbone = require('backbone'); global.Backbone.$ = global.$; -global.Marionette = require('../../../tmp/backbone.marionette'); +global.Marionette = requireHelper('backbone.marionette'); diff --git a/spec/javascripts/setup/require_helper.js b/spec/javascripts/setup/require_helper.js new file mode 100644 index 0000000000..448a2d2b75 --- /dev/null +++ b/spec/javascripts/setup/require_helper.js @@ -0,0 +1,3 @@ +module.exports = function (path) { + return require((process.env.APP_DIR_FOR_CODE_COVERAGE || '../../../tmp/') + path); +};