-
-
Save korczis/6661550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
'use strict'; | |
// Project configuration. | |
grunt.initConfig({ | |
meta : { | |
// Specify where our test files are. Once we get all the tests switched over we can use 'test/js/**/*.spec.js' to automatically load all tests. | |
specs : ['test/js/src/**/*.spec.js'], | |
bin : { | |
coverage: 'js/bin/coverage' | |
} | |
}, | |
// Our jasmine task, with a sub-task called 'test'. | |
jasmine : { | |
options : { | |
specs : '<%= meta.specs %>', | |
template: require('grunt-template-jasmine-requirejs'), | |
templateOptions: { | |
requireConfig: { | |
baseUrl: 'js/src/' | |
} | |
} | |
}, | |
test : { | |
// Run with the default settings | |
}, | |
coverage : { | |
options: { | |
templateOptions: { | |
requireConfig: { | |
baseUrl: '<%= meta.bin.coverage %>/js/src/' | |
} | |
}, | |
helpers: 'js/coverage_helper.js' | |
} | |
} | |
}, | |
// Instrument the files for coverage | |
instrument : { | |
files : 'js/src/**/*.js', | |
options : { | |
basePath : '<%= meta.bin.coverage %>' | |
} | |
}, | |
storeCoverage : { | |
options : { | |
dir : '<%= meta.bin.coverage %>' | |
} | |
}, | |
makeReport : { | |
src : '<%= meta.bin.coverage %>/*.json', | |
options : { | |
type : 'lcov', | |
dir : '<%= meta.bin.coverage %>' | |
} | |
}, | |
// Setup a simple web server that can run our tests headlessly. | |
connect: { | |
options: { | |
base: '.', | |
port: 9911 | |
}, | |
test: { | |
options: { | |
port: 9911, | |
keepalive: false | |
} | |
}, | |
runner: { | |
options: { | |
port: 9912, | |
keepalive: false | |
} | |
} | |
} | |
}); | |
grunt.loadNpmTasks('grunt-istanbul'); | |
grunt.loadNpmTasks('grunt-contrib-jasmine'); | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
/** Grunt Tasks **/ | |
// Instrument JS and run tests to get a coverage report | |
grunt.registerTask('coverage', ['instrument', 'jasmine:coverage', | |
'storeCoverage', 'makeReport']); | |
// Run tests headlessly and report the results in the command line. | |
grunt.registerTask('test', ['connect:test', 'jasmine:test']); | |
// Start a simple web server and build the spec runner. | |
// You can hit the spec runner in a browser after running this at 'http://localhost:9912/_SpecRunner.html | |
grunt.registerTask('runner', ['jasmine:test:build', 'connect:runner', 'watch:tests']); | |
// Default task. | |
grunt.registerTask('default', ['test']); | |
// needed to make grunt-istanbul storeReport | |
grunt.event.on('jasmine.coverage', function (coverage) { | |
global.__coverage__ = coverage; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment