diff --git a/.gitignore b/.gitignore index 40feb52..4d481c3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules .idea *.komodo* help -image_creator \ No newline at end of file +image_creator +tmp diff --git a/Gruntfile.js b/Gruntfile.js index b5d3138..f497dd7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -32,6 +32,10 @@ module.exports = function(grunt) { "src/end.js" ], dest: 'dist/<%= pkg.name %>.v<%= pkg.version %>.js' + }, + test: { + src: '<%= concat.dist.src %>', + dest: 'tmp/<%= pkg.name %>.js' } }, uglify: { @@ -89,6 +93,42 @@ module.exports = function(grunt) { "\n" + "\n" } + }, + karma: { + options: { + basepath: '', + frameworks: ['jasmine'], + files: [ + 'tmp/*.js', + 'test/**/*.spec.js', + 'test/*.spec.js' + ], + reporters: ['progress'], + port: 9876, + colors: true, + browsers: ['PhantomJS'] + }, + unit: { + singleRun: true + }, + continuous: { + background: true, + } + }, + watch: { + src: { + files: [ + '<%= concat.test.src %>', + ], + tasks: ['concat:test', 'karma:continuous:run'] + }, + test: { + files: [ + 'test/**/*.spec.js', + 'test/*.spec.js' + ], + tasks: ['karma:continuous:run'] + } } }); @@ -98,6 +138,8 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-qunit'); grunt.loadNpmTasks('grunt-jslint'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-karma'); // Propogate version into relevant files grunt.registerMultiTask('prop', 'Propagate Versions.', function() { @@ -131,5 +173,7 @@ module.exports = function(grunt) { // Default tasks grunt.registerTask('default', ['concat', 'jslint', 'uglify', 'connect', 'qunit', 'prop']); + grunt.registerTask('test', ['karma:continuous:start', 'watch']); + grunt.registerTask('test:unit', ['concat:test', 'karma:unit']); }; \ No newline at end of file diff --git a/package.json b/package.json index 75000c8..4542a1e 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,19 @@ "grunt-contrib-uglify": "~0.2.0", "grunt-contrib-connect": "~0.3.0", "grunt-contrib-qunit": "~0.2.2" + }, + "devDependencies": { + "karma-script-launcher": "~0.1.0", + "karma-chrome-launcher": "~0.1.2", + "karma-firefox-launcher": "~0.1.3", + "karma-html2js-preprocessor": "~0.1.0", + "karma-jasmine": "~0.1.5", + "karma-coffee-preprocessor": "~0.1.2", + "requirejs": "~2.1.10", + "karma-requirejs": "~0.2.1", + "karma-phantomjs-launcher": "~0.1.1", + "karma": "~0.10.9", + "grunt-contrib-watch": "~0.5.3", + "grunt-karma": "~0.6.2" } }