forked from mikeebowen/short-stories
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
160 lines (149 loc) · 3.9 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
'use strict';
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-simple-mocha');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-webpack');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-karma');
//initialize grunt
grunt.initConfig({
// create jshint task
jshint: {
dev: {
// tell jshint what check
src: ['Gruntfile.js', 'server.js', 'lib/**/*.js', 'models/**/*.js', 'routes/**/*.js', '!build/**', '!test/client/bundle.js', '!test/karma_tests/bundle.js'],
options: {
node: true,
globals: {
describe: true,
it: true,
before: true,
after: true,
beforeEach: true,
afterEach: true,
res: true
}
}
},
mocha: {
// tell mocha where test files are
src: ['test/**/*.js', '!test/client/bundle.js', '!test/karma_tests/bundle.js'],
options: {
node: true,
globals: {
describe: true,
it: true,
before: true,
after: true,
beforeEach: true,
afterEach: true,
res: true,
expect: true
}
}
},
jasmine: {
src: ['test/karma_tests/*test.js', 'app/js/*.js', 'app/js/*.js'],
options: {
node: true,
jasmine: true,
globals: {
describe: true,
it: true,
before: true,
after: true,
beforeEach: true,
afterEach: true,
expect: true,
react: true
}
}
},
// create jscs task
jscs: {
dev: {
// tell jscs to test the same files as jshint
src: ['<%= jshint.dev.src %>', '<%= jshint.mocha.src %>']
}
}
},
//create simplemocha task
simplemocha: {
dev: {
//tell simple mocha where the test files are
src: ['test/**/*.js', '!test/karma_tests/*']
}
},
//create task to run karma
karma: {
test: {
configFile: 'karma.conf.js'
}
},
// register webpack task
webpack: {
client: {
entry: __dirname + '/app/js/client.jsx',
output: {
path: 'build/',
file: 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx$/,
loader:'jsx-loader'
}]
}
},
test: {
entry: __dirname + '/test/client/test.js',
output: {
path: 'test/client/',
file: 'bundle.js'
}
},
karma_test: {
entry: __dirname + '/test/karma_tests/test_entry.js',
output: {
path: 'test/karma_tests/',
file: 'bundle.js'
}
}
},
copy: {
html: {
cwd: 'app/',
expand: true,
flatten: false,
src: '**/*.html',
dest: 'build/',
filter: 'isFile'
}
},
clean: {
dev: {
src: 'build/'
}
}
});
// register linting task
grunt.registerTask('lint', ['jshint:dev', 'jshint:mocha', 'jshint:jasmine']);
// register mocha test task
grunt.registerTask('mocha', ['simplemocha:dev']);
//register task for karma test
grunt.registerTask('jasmine', ['karma:test']);
// register test task for all tests
grunt.registerTask('test', ['jasmine', 'mocha']);
// register build task
grunt.registerTask('build:dev', ['webpack:client', 'copy:html', 'webpack:test']);
// register task for building karma tests
grunt.registerTask('build:karma', ['webpack:karma_test']);
// register build
grunt.registerTask('build', ['build:dev', 'build:karma']);
// register default task
grunt.registerTask('default', ['test']);
};