Set up karma test runner

master
Han Xu 2014-01-19 20:53:29 +08:00
parent 793446c795
commit 335d5b9fc3
3 changed files with 60 additions and 1 deletions

3
.gitignore vendored
View File

@ -3,4 +3,5 @@ node_modules
.idea
*.komodo*
help
image_creator
image_creator
tmp

View File

@ -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) {
"<!-- AUTOMATICALLY GENERATED CODE - PLEASE EDIT TEMPLATE INSTEAD -->\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']);
};

View File

@ -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"
}
}