forked from codecentric/movie-database-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
219 lines (208 loc) · 6.67 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
/*
* Information can be loaded from the package.json and reused in the
* Gruntfile. This is nice in order to avoid duplication of information.
*/
pkg: '<json:package.json>',
/*
* Just a definition of all the sources files and their location. We
* put them in a meta section so that we only need to declare them once.
*/
meta: {
all: ['client/**/*', 'server/**/*', 'test/**/*'],
gruntfile: 'Gruntfile.js',
server: {
src: 'server/**/*.js',
test: 'test/server/**/*.js'
},
client: {
js: ['client/js/**/*.js', '!client/js/lib/**/*'],
tests: {
ui: {
configLocal: 'test/client/ui-local.conf.js',
configSauce: 'test/client/ui-saucelabs.conf.js',
src: 'test/client/ui/**/*.js'
},
unit: {
config: 'test/client/unit.conf.js',
src: 'test/client/unit/**/*.js'
}
}
}
},
/*
* Simplemocha is executing our Mocha tests (Mocha is our test runner
* for the server-side tests).
*/
simplemocha: {
options: {
timeout: 3000,
ignoreLeaks: false,
ui: 'bdd',
reporter: 'spec'
},
all: {
src: '<%= meta.server.test %>'
}
},
/*
* Statis source code analyses. JSHint verifies that we are adhering
* to good coding styles, avoid pitfalls and much more.
* http://jshint.com/docs/
*
* We are configuring different settings for the different parts of our
* code, as browser environments are different to NodeJS environments.
*/
jshint: {
server: {
files: { src: '<%= meta.server.src %>' },
options: {
node: true,
globalstrict: true
}
},
servertest: {
files: { src: '<%= meta.server.test %>' },
options: {
node: true,
globalstrict: true,
expr: true, // to allow the use of expet(val).to.be.empty
globals: {
describe: false,
beforeEach: false,
it: false
}
}
},
gruntfile: {
files: { src: '<%= meta.gruntfile %>' },
options: {
node: true,
globalstrict: true
}
},
client: {
files: { src: '<%= meta.client.js %>' },
options: {
browser: true,
unused: false,
globals: {
angular: false
}
}
},
clientUi: {
files: { src: '<%= meta.client.tests.ui.src %>' },
options: {
node: true,
globalstrict: true,
globals: {
browser: false,
expect: false,
describe: false,
it: false,
beforeEach: false,
element: false,
by: false
}
}
},
clientUnit: {
files: { src: '<%= meta.client.tests.unit.src %>' },
options: {
newcap: false,
undef: false,
immed: false,
unused: false,
sub: false,
noempty: false,
expr: true,
globals: {
describe: false,
it: false,
chai: false
}
}
},
options: {
bitwise: true,
boss: true,
curly: true,
camelcase: true,
eqeqeq: true,
eqnull: true,
forin: true,
immed: true,
indent: 4,
latedef: true,
maxcomplexity: 6,
maxdepth: 3,
maxparams: 4,
maxstatements: 14,
maxlen: 120,
newcap: true,
noarg: true,
noempty: true,
nonew: true,
quotmark: 'single',
sub: true,
strict: true,
trailing: true,
undef: true,
unused: true
}
},
/*
* Karma is our super awesome test runner. It starts up a browser for
* you and can even observe file changes. We have our own Grunt
* plugin as we want the tests to be run asynchronously.
*/
karma: {
unit: {
configFile: '<%= meta.client.tests.unit.config %>',
browsers: ['PhantomJS'],
singleRun: true
}
},
/*
* Protractor is the preferred AngularJS test runner. It is basically
* a small wrapper around WebDriverJS and Selenium which enables
* tests of AngularJS-based applications.
*/
protractor: {
local: {
configFile: '<%= meta.client.tests.ui.configLocal %>'
},
travis: {
configFile: '<%= meta.client.tests.ui.configSauce %>'
}
},
/*
* Watch is handy when you want to execute tasks upon file changes, e.g.
* execute tests and static source code analysis.
*/
watch: {
files: '<%= meta.all %>',
tasks: ['jshint', 'simplemocha', 'karma:unit']
}
});
require('load-grunt-tasks')(grunt);
grunt.loadTasks('./tasks');
grunt.registerTask('travis', [
'jshint',
'simplemocha',
'karma:unit',
'server',
'protractor:travis'
]);
grunt.registerTask('test', [
'jshint',
'simplemocha',
'karma:unit',
'server',
'protractor:local'
]);
grunt.registerTask('dev', ['server', 'watch']);
};