1
|
'use strict';
|
2
|
|
3
|
module.exports = function (grunt) {
|
4
|
|
5
|
// Project configuration.
|
6
|
grunt.initConfig({
|
7
|
// Metadata.
|
8
|
pkg: grunt.file.readJSON('package.json'),
|
9
|
banner: '/*! <%= pkg.name %> - v<%= pkg.version %>' +
|
10
|
' - <%= pkg.homepage %>' +
|
11
|
' - (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
|
12
|
' - licensed <%= pkg.license %> */\n',
|
13
|
// Task configuration.
|
14
|
concat: {
|
15
|
options: {
|
16
|
banner: '<%= banner %>',
|
17
|
stripBanners: true
|
18
|
},
|
19
|
dist: {
|
20
|
src: ['lib/<%= pkg.name %>.js'],
|
21
|
dest: 'dist/<%= pkg.name %>.js'
|
22
|
}
|
23
|
},
|
24
|
uglify: {
|
25
|
options: {
|
26
|
banner: '<%= banner %>'
|
27
|
},
|
28
|
dist: {
|
29
|
src: '<%= concat.dist.dest %>',
|
30
|
dest: 'dist/<%= pkg.name %>.min.js'
|
31
|
}
|
32
|
},
|
33
|
jasmine: {
|
34
|
requirejs: {
|
35
|
src: [],
|
36
|
options: {
|
37
|
specs: 'test/*-test.js',
|
38
|
vendor: 'test/vendor/*.js',
|
39
|
helpers: 'test/*-helper.js',
|
40
|
template: require('grunt-template-jasmine-requirejs')
|
41
|
}
|
42
|
},
|
43
|
global: {
|
44
|
src: 'lib/**/*.js',
|
45
|
options: {
|
46
|
specs: 'test/global-integration.js',
|
47
|
vendor: 'test/vendor/*.js'
|
48
|
}
|
49
|
},
|
50
|
context: {
|
51
|
src: 'test/test-context-using-apply.generated.js',
|
52
|
options: {
|
53
|
specs: 'test/global-integration-with-new-context.js',
|
54
|
vendor: 'test/vendor/*.js'
|
55
|
}
|
56
|
},
|
57
|
withCoverage: {
|
58
|
src: 'lib/**/*.js',
|
59
|
options: {
|
60
|
specs: 'test/*-test.js',
|
61
|
vendor: 'test/vendor/*.js',
|
62
|
helpers: 'test/*-helper.js',
|
63
|
template: require('grunt-template-jasmine-istanbul'),
|
64
|
templateOptions: {
|
65
|
coverage: 'coverage/coverage.json',
|
66
|
report: [
|
67
|
{
|
68
|
type: 'html',
|
69
|
options: {
|
70
|
dir: 'coverage'
|
71
|
}
|
72
|
},
|
73
|
{
|
74
|
type: 'lcov',
|
75
|
options: {
|
76
|
dir: 'coverage'
|
77
|
}
|
78
|
}
|
79
|
],
|
80
|
|
81
|
template: require('grunt-template-jasmine-requirejs'),
|
82
|
templateOptions: {
|
83
|
requireConfig: {
|
84
|
paths: {
|
85
|
"lib": '.grunt/grunt-contrib-jasmine/lib/'
|
86
|
}
|
87
|
}
|
88
|
}
|
89
|
}
|
90
|
}
|
91
|
}
|
92
|
},
|
93
|
"jasmine_node": {
|
94
|
test: {
|
95
|
options: {
|
96
|
match: "node-integration.",
|
97
|
matchall: true,
|
98
|
projectRoot: "./test",
|
99
|
useHelpers: false
|
100
|
}
|
101
|
}
|
102
|
},
|
103
|
coveralls: {
|
104
|
src: 'coverage/lcov.info'
|
105
|
},
|
106
|
open: {
|
107
|
jasmine: {
|
108
|
path: 'http://127.0.0.1:8000/_SpecRunner.html'
|
109
|
}
|
110
|
},
|
111
|
connect: {
|
112
|
test: {
|
113
|
port: 8000,
|
114
|
keepalive: true
|
115
|
}
|
116
|
},
|
117
|
'saucelabs-jasmine': {
|
118
|
// Requires valid SAUCE_USERNAME and SAUCE_ACCESS_KEY in env to run.
|
119
|
all: {
|
120
|
options: {
|
121
|
urls: ['http://localhost:8000/_SpecRunner.html'],
|
122
|
browsers: [
|
123
|
{"browserName": "firefox", "platform": "Windows 2003", "version": "3.6"},
|
124
|
{"browserName": "firefox", "platform": "Windows 2003", "version": "4"},
|
125
|
{"browserName": "firefox", "platform": "Windows 2003", "version": "25"},
|
126
|
{"browserName": "safari", "platform": "Mac 10.6", "version": "5"},
|
127
|
{"browserName": "safari", "platform": "Mac 10.8", "version": "6"},
|
128
|
{"browserName": "googlechrome", "platform": "Windows 7"},
|
129
|
{"browserName": "opera", "platform": "Windows 2003", "version": "12"},
|
130
|
// Disabled because old IE breaks the Jasmine runner; these have to be manually tested
|
131
|
// {"browserName": "iehta", "platform": "Windows XP", "version": "6"},
|
132
|
// {"browserName": "iehta", "platform": "Windows XP", "version": "7"},
|
133
|
// {"browserName": "iehta", "platform": "Windows XP", "version": "8"},
|
134
|
{"browserName": "iehta", "platform": "Windows 7", "version": "9"},
|
135
|
{"browserName": "iehta", "platform": "Windows 7", "version": "10"},
|
136
|
{"browserName": "opera", "platform": "Windows 7", "version": "12"},
|
137
|
{"browserName": "android", "platform": "Linux", "version": "4.0"},
|
138
|
{"browserName": "iphone", "platform": "OS X 10.8", "version": "6"}
|
139
|
],
|
140
|
concurrency: 3,
|
141
|
detailedError: true,
|
142
|
testTimeout:10000,
|
143
|
testInterval:1000,
|
144
|
testReadyTimeout:2000,
|
145
|
testname: 'loglevel jasmine test',
|
146
|
tags: [process.env.TRAVIS_REPO_SLUG || "local", process.env.TRAVIS_COMMIT || "manual"]
|
147
|
}
|
148
|
}
|
149
|
},
|
150
|
jshint: {
|
151
|
options: {
|
152
|
jshintrc: '.jshintrc'
|
153
|
},
|
154
|
gruntfile: {
|
155
|
src: 'Gruntfile.js'
|
156
|
},
|
157
|
lib: {
|
158
|
options: {
|
159
|
jshintrc: 'lib/.jshintrc'
|
160
|
},
|
161
|
src: ['lib/**/*.js']
|
162
|
},
|
163
|
test: {
|
164
|
options: {
|
165
|
jshintrc: 'test/.jshintrc'
|
166
|
},
|
167
|
src: ['test/*.js', '!test/*.generated.js']
|
168
|
}
|
169
|
},
|
170
|
watch: {
|
171
|
gruntfile: {
|
172
|
files: '<%= jshint.gruntfile.src %>',
|
173
|
tasks: ['jshint:gruntfile']
|
174
|
},
|
175
|
lib: {
|
176
|
files: '<%= jshint.lib.src %>',
|
177
|
tasks: ['jshint:lib', 'test']
|
178
|
},
|
179
|
test: {
|
180
|
files: '<%= jshint.test.src %>',
|
181
|
tasks: ['jshint:test', 'test']
|
182
|
}
|
183
|
},
|
184
|
qunit: {
|
185
|
all: ['test/*-qunit.html']
|
186
|
},
|
187
|
preprocess: {
|
188
|
"test-context-using-apply": {
|
189
|
src: 'test/test-context-using-apply.js',
|
190
|
dest: 'test/test-context-using-apply.generated.js'
|
191
|
}
|
192
|
},
|
193
|
clean:{
|
194
|
test:['test/test-context-using-apply.generated.js']
|
195
|
}
|
196
|
});
|
197
|
|
198
|
// These plugins provide necessary tasks.
|
199
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
200
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
201
|
grunt.loadNpmTasks('grunt-contrib-jasmine');
|
202
|
grunt.loadNpmTasks('grunt-coveralls');
|
203
|
grunt.loadNpmTasks('grunt-jasmine-node');
|
204
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
205
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
206
|
grunt.loadNpmTasks('grunt-contrib-qunit');
|
207
|
|
208
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
209
|
grunt.loadNpmTasks('grunt-open');
|
210
|
grunt.loadNpmTasks('grunt-saucelabs');
|
211
|
grunt.loadNpmTasks('grunt-preprocess');
|
212
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
213
|
|
214
|
// Build a distributable release
|
215
|
grunt.registerTask('dist', ['test', 'concat', 'uglify']);
|
216
|
|
217
|
// Check everything is good
|
218
|
grunt.registerTask('test', ['jshint', 'jasmine:requirejs', 'jasmine:global', 'preprocess', 'jasmine:context', 'clean:test', 'jasmine_node', 'jasmine:withCoverage', 'qunit']);
|
219
|
|
220
|
// Test with a live server and an actual browser
|
221
|
grunt.registerTask('integration-test', ['jasmine:requirejs:src:build', 'open:jasmine', 'connect:test:keepalive']);
|
222
|
|
223
|
// Test with lots of browsers on saucelabs. Requires valid SAUCE_USERNAME and SAUCE_ACCESS_KEY in env to run.
|
224
|
grunt.registerTask('saucelabs', ['jasmine:requirejs:src:build', 'connect:test', 'saucelabs-jasmine']);
|
225
|
|
226
|
// Default task.
|
227
|
grunt.registerTask('default', 'test');
|
228
|
grunt.registerTask('ci', ['test', 'coveralls']);
|
229
|
|
230
|
};
|