mocha support!

This commit is contained in:
Gustavo Cortez 2014-01-06 18:38:30 -03:00
parent be497058fc
commit ade4053e01
3 changed files with 27 additions and 5 deletions

View File

@ -61,6 +61,13 @@ module.exports = function(grunt) {
logConcurrentOutput: true logConcurrentOutput: true
} }
}, },
mochaTest: {
options: {
reporter: 'spec',
require: 'server.js'
},
src: ['test/*.js']
},
env: { env: {
test: { test: {
NODE_ENV: 'test' NODE_ENV: 'test'
@ -71,6 +78,7 @@ module.exports = function(grunt) {
//Load NPM tasks //Load NPM tasks
grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-nodemon'); grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent'); grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-env'); grunt.loadNpmTasks('grunt-env');
@ -80,4 +88,7 @@ module.exports = function(grunt) {
//Default task(s). //Default task(s).
grunt.registerTask('default', ['jshint', 'concurrent']); grunt.registerTask('default', ['jshint', 'concurrent']);
//Test task.
grunt.registerTask('test', ['env:test', 'mochaTest']);
}; };

View File

@ -47,12 +47,14 @@
"grunt-contrib-jshint": "~0.8.0", "grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-watch": "~0.5.3", "grunt-contrib-watch": "~0.5.3",
"grunt-concurrent": "~0.4.2", "grunt-concurrent": "~0.4.2",
"grunt-nodemon": "~0.1.2" "grunt-nodemon": "~0.1.2",
"grunt-mocha-test": "~0.8.1"
}, },
"devDependencies": { "devDependencies": {
"grunt-contrib-watch": "~0.5.3", "grunt-contrib-watch": "latest",
"grunt-contrib-jshint": "~0.8.0", "grunt-contrib-jshint": "latest",
"grunt-nodemon": "~0.1.2", "grunt-nodemon": "latest",
"grunt-concurrent": "~0.4.2" "grunt-concurrent": "latest",
"grunt-mocha-test": "latest"
} }
} }

9
test/test.js Normal file
View File

@ -0,0 +1,9 @@
var assert = require("assert")
describe('Array', function(){
describe('#indexOf()', function(){
it('should return -1 when the value is not present', function(){
assert.equal(-1, [1,2,3].indexOf(5));
assert.equal(-1, [1,2,3].indexOf(0));
})
})
})