/
Gruntfile.js
110 lines (103 loc) · 3.13 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'use strict';
var path = require('path');
module.exports = function (grunt) {
var port = 3020;
// Project configuration.
grunt.initConfig({
mochacli: {
options: {
require: [],
reporter: 'spec',
bail: true
},
all:['test/**/*_test.js']
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
app: {
src: ['src/**/*.js', "!src/public/lib/**/*.js", "!src/public/javascripts/vendor/**/*.js"]
},
test: {
src: ['test/**/*.js', "!test/lib/**/*.js", "!test/unit/**/*.js", "!test/e2e/**/*.js"]
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
app: {
files: '<%= jshint.app.src %>',
tasks: ['jshint:app', 'nodeunit']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'nodeunit']
}
},
karma: {
unit: {
configFile: 'config/karma.conf.js',
singleRun: true
},
watch: {
configFile: 'config/karma.conf.js',
singleRun: false,
autoWatch: true,
browsers: ['PhantomJS']
},
e2e: {
configFile: 'config/karma-e2e.conf.js',
singleRun: true,
autoWatch: false,
proxies: {
'/': 'http://localhost:' + port + '/'
}
}
},
express: {
server: {
options: {
hostname: 'localhost',
port: port,
bases: path.resolve('./src/public'),
server: path.resolve('./src/app')
}
}
},
env: {
options: {
//Shared Options Hash
},
test: {
NODE_ENV: 'test'
},
dev: {
NODE_ENV: 'development'
},
build: {
NODE_ENV: 'production'
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-express');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-mocha-cli');
// note: to run karma in continuous (autowatch) mode, run it directly:
// unit tests:
// karma start config/karma.conf.js
// e2e tests:
// karma start config/karma-e2e.conf.js
grunt.registerTask('default', ['env:test', 'jshint:app', 'test', 'e2e']);
grunt.registerTask('e2e', ['env:test', 'express', 'karma:e2e']);
grunt.registerTask('test', ['env:test', 'mochacli:all', 'karma:unit']);
};