jade task only prepares the "files" template var for templates in the unit test dir and ignores .jade files who's filename start with an underscore.

watch:test only watches the test's js files and runs the tests when they change.
This commit is contained in:
Spencer Alger 2014-03-05 14:13:23 -07:00
parent 3f0eb9a7ce
commit 40b3021e48
4 changed files with 38 additions and 21 deletions

View file

@ -1,24 +1,34 @@
module.exports = function (grunt) {
var path = require('path');
return {
test: {
all: {
src: [
'<%= unitTestDir %>/**/*.jade',
'<%= app %>/partials/**/*.jade',
'<%= app %>/apps/**/*.jade'
'<%= app %>/apps/**/*.jade',
'<%= root %>/test/**/*.jade',
'!<%= root %>/**/_*.jade'
],
expand: true,
ext: '.html',
options: {
data: function (src, dest) {
var pattern = grunt.config.process('<%= unitTestDir %>/**/*.js');
var tests = grunt.file.expand({}, pattern).map(function (filename) {
return filename.replace(grunt.config.get('unitTestDir'), '');
});
return { tests: JSON.stringify(tests) };
var unitTestDir = grunt.config.get('unitTestDir');
// filter for non unit test related files
if (!~path.dirname(src).indexOf(unitTestDir)) return;
var pattern = unitTestDir + '/specs/**/*.js';
var appdir = grunt.config.get('app');
return {
tests: grunt.file.expand({}, pattern).map(function (filename) {
return path.relative(appdir, filename).replace(/\.js$/, '');
})
};
},
client: false
}
}
};
};
};

View file

@ -3,7 +3,12 @@ module.exports = function (config) {
// just lint the source dir
source: {
files: {
src: ['Gruntfile.js', '<%= src %>/**/*.js', '<%= unitTestDir %>/**/*.js', '<%= root %>/tasks/**/*.js']
src: [
'Gruntfile.js',
'<%= src %>/**/*.js',
'<%= unitTestDir %>/**/*.js',
'<%= root %>/tasks/**/*.js'
]
}
},
options: {

View file

@ -1,12 +1,14 @@
module.exports = {
options: {
log: true,
logErrors: true,
run: false
},
unit: {
options: {
log: true,
logErrors: true,
urls: [
'http://localhost:8001/'
],
run: false
'http://localhost:8000/test/unit/'
]
}
}
};

View file

@ -1,8 +1,8 @@
module.exports = function (grunt) {
return {
test: {
files: ['<%= unitTestDir %>/*.jade', '<%= unitTestDir %>/**/*.js'],
tasks: ['jade:test', 'mocha:unit']
files: ['<%= unitTestDir %>/**/*.js'],
tasks: ['mocha:unit']
},
less: {
files: [
@ -13,9 +13,9 @@ module.exports = function (grunt) {
},
jade: {
files: [
'<%= app %>/**/*.jade',
'<%= src %>/courier/**/*.jade',
'!<%= unitTestDir %>/**/*.jade'
'<%= root %>/**/*.jade',
'!<%= root %>/node_modules/**/*',
'!<%= src %>/bower_components/**/*'
],
tasks: ['jade']
}