-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
95 lines (88 loc) · 3.01 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
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
run: {
jasmine_node_with_coverage: {
cmd: 'node_modules/.bin/grunt',
args: ['jasmine_node_with_coverage']
},
jasmine_node_with_coverage_quiet: {
cmd: 'node_modules/.bin/grunt',
args: ['jasmine_node_with_coverage'],
options: {
quiet: true
}
}
},
clean: {
all: 'coverage'
},
jshint: {
all: [
'Gruntfile.js',
'test/**/*.js',
'lib/**/*.js',
'example/**/*.js'
],
options: {
jshintrc: '.jshintrc'
}
},
jasmine_node_no_coverage: {
coverage: false,
options: {
matchall: true,
specFolders: ['test/spec/'],
isVerbose: true
}
},
jasmine_node_with_coverage: {
coverage: {
excludes: ['test/**', 'coverage/**', 'Gruntfile.js', 'example/**']
},
options: {
matchall: true,
specFolders: ['test/spec/'],
isVerbose: true
}
},
coveralls: {
all: {
src: './coverage/lcov.info'
}
},
watch: {
js: {
files: ['**/*.js', '!node_modules/**/*.js', '!coverage/**/*.js'],
tasks: ['default'],
options: {
spawn: true // Since livereload seems not to be working we spawn to require the latest index.js
}
}
}
});
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jasmine-node-coverage');
grunt.loadNpmTasks('grunt-coveralls');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('jasmine_node_no_coverage', 'Just unit testing', function () {
grunt.config.set('jasmine_node', grunt.config.get('jasmine_node_no_coverage'));
grunt.task.run('jasmine_node');
});
grunt.registerTask('jasmine_node_with_coverage', 'Unit testing with coverage report', function () {
grunt.config.set('jasmine_node', grunt.config.get('jasmine_node_with_coverage'));
grunt.task.run('jasmine_node');
});
// 'jasmine-node' needs to run in a separate task because the coverage report is created when grunt exits.
// When we use watch grunt keeps running and no report would be generated if 'jasmine-node' would be executed directly.
grunt.registerTask('test', ['clean', 'jshint', 'run:jasmine_node_with_coverage', 'watch']);
grunt.registerTask('test_no_coverage', ['clean', 'jshint', 'jasmine_node_no_coverage', 'watch']);
// 'jasmine-node' needs to run in a separate task the second time it is executed so that es-sequence freshly required.
// The unit tests assume that es-sequence is not initialized in the beginning.
grunt.registerTask('ci', ['clean', 'jshint', 'jasmine_node_no_coverage', 'run:jasmine_node_with_coverage_quiet', 'coveralls']);
grunt.registerTask('ci_no_coverage', ['clean', 'jshint', 'jasmine_node_no_coverage']);
grunt.registerTask('default', ['test']);
};