forked from mozilla-b2g/firefoxos-loop-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
102 lines (93 loc) · 2.15 KB
/
Gruntfile.js
File metadata and controls
102 lines (93 loc) · 2.15 KB
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
'use strict';
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
module.exports = function(grunt) {
[
'grunt-contrib-clean',
'grunt-contrib-copy',
'grunt-contrib-connect',
'grunt-mocha',
'grunt-html-build'
].forEach(grunt.loadNpmTasks);
grunt.initConfig({
connect: {
test: {
options: {
port: 9002,
middleware: function (connect) {
return [
mountFolder(connect, '.tmp'),
mountFolder(connect, 'test'),
mountFolder(connect, 'app')
];
}
}
}
},
mocha: {
all: {
options: {
run: true,
urls: ['http://0.0.0.0:9002/index.html'],
bail: true,
logErrors: true,
reporter: 'Spec'
}
}
},
clean: {
server: [
'.tmp'
],
preTest: [
'test/index.html'
],
postTest: [
'src/'
]
},
copy: {
test: {
files: [{
expand: true,
cwd: 'src',
src: ['index.template.html'],
dest: 'test',
rename: function() {
return 'test/index.html';
}
}]
}
},
// We use htmlbuild to add the tests dependencies to test/index.html
// This avoid us to manually add the dependencies every time we add a
// new test or script file.
htmlbuild: {
src: 'test/index.template.html',
// "dest" is not working with the current htmlbuild version, so we need
// to manually move src/index.html to test/index.html
// dest: 'test/',
options: {
beautify: true,
relative: true,
scripts: {
libs: 'app/libs/*.js',
tokbox: 'app/libs/tokbox/**/*.js',
helpers: 'app/js/helpers/*.js',
screens: 'app/js/screens/*.js',
js: 'app/js/*.js',
}
}
}
});
grunt.registerTask('test', 'Launch tests in shell with PhantomJS', [
'clean:server',
'clean:preTest',
'htmlbuild',
'copy:test',
'clean:postTest',
'connect:test',
'mocha'
]);
};